diff options
Diffstat (limited to 'busybox/libbb/bb_asprintf.c')
-rw-r--r-- | busybox/libbb/bb_asprintf.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/busybox/libbb/bb_asprintf.c b/busybox/libbb/bb_asprintf.c new file mode 100644 index 000000000..a3ba42454 --- /dev/null +++ b/busybox/libbb/bb_asprintf.c | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | Copyright (C) 2002 Vladimir Oleynik <dzo@simtreas.ru> | ||
3 | */ | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | #include <stdio.h> | ||
7 | #include <stdarg.h> | ||
8 | #include "libbb.h" | ||
9 | |||
10 | void bb_xasprintf(char **string_ptr, const char *format, ...) | ||
11 | { | ||
12 | va_list p; | ||
13 | int r; | ||
14 | |||
15 | va_start(p, format); | ||
16 | r = vasprintf(string_ptr, format, p); | ||
17 | va_end(p); | ||
18 | |||
19 | if (r < 0) { | ||
20 | bb_perror_msg_and_die("bb_xasprintf"); | ||
21 | } | ||
22 | } | ||