pxe: Fix recognition of keeppxe option
[syslinux.git] / com32 / lib / asprintf.c
blobeab20118860cefd912854b5dca68d772b704ee4b
1 /*
2 * asprintf.c
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <stdarg.h>
9 int asprintf(char **bufp, const char *format, ...)
11 va_list ap, ap1;
12 int rv;
13 int bytes;
14 char *p;
16 va_start(ap, format);
17 va_copy(ap1, ap);
19 bytes = vsnprintf(NULL, 0, format, ap1) + 1;
20 va_end(ap1);
22 *bufp = p = malloc(bytes);
23 if (!p)
24 rv = -1;
25 else
26 rv = vsnprintf(p, bytes, format, ap);
28 va_end(ap);
30 return rv;