blob: 7075b46deadd24825f1d3cbd7d978900dfa98804 [file] [log] [blame]
Robert Grieblefd49832002-07-19 20:27:11 +00001/*
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 4d0884a2002-09-12 14:52:26 +00008#include "libbb.h"
Robert Grieblefd49832002-07-19 20:27:11 +00009
Manuel Novoa III cad53642003-03-19 09:13:01 +000010void bb_xasprintf(char **string_ptr, const char *format, ...)
Robert Grieblefd49832002-07-19 20:27:11 +000011{
Manuel Novoa III cad53642003-03-19 09:13:01 +000012 va_list p;
13 int r;
14
15 va_start(p, format);
16 r = vasprintf(string_ptr, format, p);
17 va_end(p);
Robert Grieblefd49832002-07-19 20:27:11 +000018
Manuel Novoa III cad53642003-03-19 09:13:01 +000019 if (r < 0) {
20 bb_perror_msg_and_die("bb_xasprintf");
21 }
Robert Grieblefd49832002-07-19 20:27:11 +000022}