summaryrefslogtreecommitdiff
path: root/include/scratch_buffer.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 16:39:27 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 16:39:27 +0000
commit52629237a522c7c146d788ddaaf69946fd2729f9 (patch)
tree552402b085cff37bc251fc0f45ed9255b53cdd57 /include/scratch_buffer.h
parent3896c5809b49e72fbadc57da2189ff42aa2a5d02 (diff)
parent064374be911f72dfaec8a75f06da1f9fc1827712 (diff)
Merge commit 'refs/top-bases/t/hurdsig-boot-fix' into t/hurdsig-boot-fix
Diffstat (limited to 'include/scratch_buffer.h')
-rw-r--r--include/scratch_buffer.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/include/scratch_buffer.h b/include/scratch_buffer.h
index c59e143d77..32552ee940 100644
--- a/include/scratch_buffer.h
+++ b/include/scratch_buffer.h
@@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
- Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ Copyright (C) 2015-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -66,8 +66,7 @@
struct scratch_buffer {
void *data; /* Pointer to the beginning of the scratch area. */
size_t length; /* Allocated space at the data pointer, in bytes. */
- char __space[1024]
- __attribute__ ((aligned (__alignof__ (max_align_t))));
+ union { max_align_t __align; char __c[1024]; } __space;
};
/* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space
@@ -75,7 +74,7 @@ struct scratch_buffer {
static inline void
scratch_buffer_init (struct scratch_buffer *buffer)
{
- buffer->data = buffer->__space;
+ buffer->data = buffer->__space.__c;
buffer->length = sizeof (buffer->__space);
}
@@ -83,7 +82,7 @@ scratch_buffer_init (struct scratch_buffer *buffer)
static inline void
scratch_buffer_free (struct scratch_buffer *buffer)
{
- if (buffer->data != buffer->__space)
+ if (buffer->data != buffer->__space.__c)
free (buffer->data);
}