source: bootcd/isolinux/syslinux-6.03/com32/lib/asprintf.c

Last change on this file was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 449 bytes
Line 
1/*
2 * asprintf.c
3 */
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <stdarg.h>
8
9int asprintf(char **bufp, const char *format, ...)
10{
11    va_list ap, ap1;
12    int rv;
13    int bytes;
14    char *p;
15
16    va_start(ap, format);
17    va_copy(ap1, ap);
18
19    bytes = vsnprintf(NULL, 0, format, ap1) + 1;
20    va_end(ap1);
21
22    *bufp = p = malloc(bytes);
23    if (!p)
24        rv = -1;
25    else
26        rv = vsnprintf(p, bytes, format, ap);
27
28    va_end(ap);
29
30    return rv;
31}
Note: See TracBrowser for help on using the repository browser.