Annotation of /trunk/mkinitrd-magellan/klibc/usr/klibc/vasprintf.c
Parent Directory | Revision Log
Revision 532 -
(hide annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 356 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 356 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | niro | 532 | /* |
2 | * vasprintf.c | ||
3 | */ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include <stdarg.h> | ||
8 | |||
9 | int vasprintf(char **bufp, const char *format, va_list ap) | ||
10 | { | ||
11 | va_list ap1; | ||
12 | int bytes; | ||
13 | char *p; | ||
14 | |||
15 | va_copy(ap1, ap); | ||
16 | |||
17 | bytes = vsnprintf(NULL, 0, format, ap1) + 1; | ||
18 | va_end(ap1); | ||
19 | |||
20 | *bufp = p = malloc(bytes); | ||
21 | if (!p) | ||
22 | return -1; | ||
23 | |||
24 | return vsnprintf(p, bytes, format, ap); | ||
25 | } |