From 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 12 Feb 2011 00:22:29 -0500 Subject: initial check-in, version 0.5.0 --- src/stdio/vasprintf.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/stdio/vasprintf.c (limited to 'src/stdio/vasprintf.c') diff --git a/src/stdio/vasprintf.c b/src/stdio/vasprintf.c new file mode 100644 index 00000000..f2bbc7aa --- /dev/null +++ b/src/stdio/vasprintf.c @@ -0,0 +1,27 @@ +#include +#include +#include + +#define GUESS 240U + +int vasprintf(char **s, const char *fmt, va_list ap) +{ + va_list ap2; + char *a; + int l=GUESS; + + if (!(a=malloc(GUESS))) return -1; + + va_copy(ap2, ap); + l=vsnprintf(a, GUESS, fmt, ap2); + va_end(ap2); + + if (l