This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] Use C11 _Alignas on scratch_buffer internal buffer


On Sep 19 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> diff --git a/include/scratch_buffer.h b/include/scratch_buffer.h
> index bb04662..0f49dd9 100644
> --- a/include/scratch_buffer.h
> +++ b/include/scratch_buffer.h
> @@ -66,7 +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.  */
> -  max_align_t __space[(1023 + sizeof (max_align_t)) / sizeof (max_align_t)];
> +  union { max_align_t __a; char __c[1024]; } __space;

If you make it an anonymous union you don't even need to change the rest
of the code.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]