[PATCH] libio: Add small optimization on fmemopen
Paul Eggert
eggert@cs.ucla.edu
Wed Sep 21 17:22:00 GMT 2016
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.
More information about the Libc-alpha
mailing list