introduce sasprintf() in libi3, use it everywhere

This commit is contained in:
Michael Stapelberg
2011-10-23 13:16:56 +01:00
parent 14abafb3c8
commit 9d15a00ba8
18 changed files with 68 additions and 66 deletions

View File

@ -10,6 +10,8 @@
*/
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <err.h>
@ -45,3 +47,14 @@ char *sstrdup(const char *str) {
err(EXIT_FAILURE, "strdup()");
return result;
}
int sasprintf(char **strp, const char *fmt, ...) {
va_list args;
int result;
va_start(args, fmt);
if ((result = vasprintf(strp, fmt, args)) == -1)
err(EXIT_FAILURE, "asprintf(%s)", fmt);
va_end(args);
return result;
}