This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] libio: Add small optimization on fmemopen
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, libc-alpha at sourceware dot org
- Date: Wed, 21 Sep 2016 10:22:46 -0700
- Subject: Re: [PATCH] libio: Add small optimization on fmemopen
- Authentication-results: sourceware.org; auth=none
- References: <1474466758-26544-1-git-send-email-adhemerval.zanella@linaro.org>
On 09/21/2016 07:05 AM, Adhemerval Zanella wrote:
+ clen += len;
That might cause problems , as the C standard says you can't access a
flexible array member past the last byte that is properly aligned for
the containing structure, and GCC relies on this when generating code
(see GCC bug 66661). One way to work around the problem is to change the
earlier:
+ size_t clen = sizeof (fmemopen_cookie_t);
to:
+ size_t clen = sizeof (fmemopen_cookie_t) + _Alignof
(fmemopen_cookie_t) - 1;
This may overallocate a bit, but that's OK here.