Adding upstream version 3.50~pre5.
[syslinux-debian/hramrach.git] / com32 / lib / vasprintf.c
blob910e7d95208a3ca884f115221b830b58a9730ca1
1 /*
2 * vasprintf.c
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <stdarg.h>
9 int vasprintf(char **bufp, const char *format, va_list ap)
11 va_list ap1;
12 int bytes;
13 char *p;
15 va_copy(ap1, ap);
17 bytes = vsnprintf(NULL, 0, format, ap1) + 1;
18 va_end(ap1);
20 *bufp = p = malloc(bytes);
21 if ( !p )
22 return -1;
24 return vsnprintf(p, bytes, format, ap);