summaryrefslogtreecommitdiff
path: root/include/scratch_buffer.h
diff options
context:
space:
mode:
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);
}