Robert Griebl | efd4983 | 2002-07-19 20:27:11 +0000 | [diff] [blame] | 1 | /* |
2 | Copyright (C) 2002 Vladimir Oleynik <dzo@simtreas.ru> | ||||
3 | */ | ||||
4 | |||||
5 | #include <stdlib.h> | ||||
6 | #include <stdio.h> | ||||
7 | #include <stdarg.h> | ||||
Manuel Novoa III | 4d0884a | 2002-09-12 14:52:26 +0000 | [diff] [blame] | 8 | #include "libbb.h" |
Robert Griebl | efd4983 | 2002-07-19 20:27:11 +0000 | [diff] [blame] | 9 | |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 10 | void bb_xasprintf(char **string_ptr, const char *format, ...) |
Robert Griebl | efd4983 | 2002-07-19 20:27:11 +0000 | [diff] [blame] | 11 | { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 12 | va_list p; |
13 | int r; | ||||
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame^] | 14 | |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 15 | va_start(p, format); |
16 | r = vasprintf(string_ptr, format, p); | ||||
17 | va_end(p); | ||||
Robert Griebl | efd4983 | 2002-07-19 20:27:11 +0000 | [diff] [blame] | 18 | |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 19 | if (r < 0) { |
20 | bb_perror_msg_and_die("bb_xasprintf"); | ||||
21 | } | ||||
Robert Griebl | efd4983 | 2002-07-19 20:27:11 +0000 | [diff] [blame] | 22 | } |