Reduce the initial buffer size for open_memstream
commit5a233790c38323afaed5ede000e1ef1234755ad7
authorWaldemar Brodkorb <wbx@openadk.org>
Sun, 6 Dec 2015 17:05:32 +0000 (6 18:05 +0100)
committerWaldemar Brodkorb <wbx@openadk.org>
Wed, 9 Dec 2015 06:50:59 +0000 (9 07:50 +0100)
treef674e420e0871491e1dad7bf584226fffdfaf5d1
parentb6af57f98021bc3b1b8183cfb501a5c45293cdd7
Reduce the initial buffer size for open_memstream

Reduce the initial buffer size for open_memstream (used by vasprintf),
as most strings are usually smaller than that.
Realloc the buffer after finishing the string to further reduce size.

Problem appears in case of UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y,
see http://dev.openwrt.org/ticket/13024

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
libc/stdio/open_memstream.c
libc/stdio/vasprintf.c
test/malloc/tst-asprintf.c [new file with mode: 0644]