From 5a233790c38323afaed5ede000e1ef1234755ad7 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 6 Dec 2015 18:05:32 +0100 Subject: 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 Signed-off-by: Leonid Lisovskiy Signed-off-by: Waldemar Brodkorb --- libc/stdio/vasprintf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libc/stdio/vasprintf.c') diff --git a/libc/stdio/vasprintf.c b/libc/stdio/vasprintf.c index a901ee815..fa7926c60 100644 --- a/libc/stdio/vasprintf.c +++ b/libc/stdio/vasprintf.c @@ -39,6 +39,8 @@ int vasprintf(char **__restrict buf, const char * __restrict format, if (rv < 0) { free(*buf); *buf = NULL; + } else { + *buf = realloc(*buf, rv + 1); } } -- cgit v1.2.3