[PATCH] libio: Add small optimization on fmemopen

Florian Weimer fweimer@redhat.com
Wed Sep 21 14:57:00 GMT 2016


On 09/21/2016 04:05 PM, Adhemerval Zanella wrote:
> This patch uses C99 variable-lenght array on internal fmemopen cookie
> allocation to avoid to use two mallocs for the case if an internal
> buffer must be allocated.  No functional changes are done.
>
> Tested on x86_64 and i686.
>
> 	* libio/fmemopen.c (fmemopen_cookie_t): Remove mybuffer and add
> 	variable-length array member.
> 	(fmemopen_close): Do no free the internal buffer.
> 	(__fmemopen): Use C99 variable-length array to allocate both the
> 	fmemopen cookie and internal buffer (for null arguments).

It's a flexible array member, not a variable-length array.  Looks good 
to me.

What about libio/oldfmemopen.c?  Do you want to touch this as well?

Thanks,
Florian



More information about the Libc-alpha mailing list