diff options
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/xfuncs_printf.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 5d26e2bfa..ed10084b3 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
| @@ -349,6 +349,22 @@ char* FAST_FUNC xasprintf(const char *format, ...) | |||
| 349 | return string_ptr; | 349 | return string_ptr; |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | char* FAST_FUNC xasprintf_and_free(char *allocated, const char *format, ...) | ||
| 353 | { | ||
| 354 | va_list p; | ||
| 355 | int r; | ||
| 356 | char *string_ptr; | ||
| 357 | |||
| 358 | va_start(p, format); | ||
| 359 | r = vasprintf(&string_ptr, format, p); | ||
| 360 | va_end(p); | ||
| 361 | |||
| 362 | if (r < 0) | ||
| 363 | bb_die_memory_exhausted(); | ||
| 364 | free(allocated); | ||
| 365 | return string_ptr; | ||
| 366 | } | ||
| 367 | |||
| 352 | void FAST_FUNC xsetenv(const char *key, const char *value) | 368 | void FAST_FUNC xsetenv(const char *key, const char *value) |
| 353 | { | 369 | { |
| 354 | if (setenv(key, value, 1)) | 370 | if (setenv(key, value, 1)) |
