add xasprintf() for upcoming changes.

This commit is contained in:
okan
2012-11-28 14:32:44 +00:00
parent 2b9d921eda
commit 3e151f8c76
2 changed files with 19 additions and 0 deletions

View File

@ -69,3 +69,19 @@ xstrdup(const char *str)
return (p);
}
int
xasprintf(char **ret, const char *fmt, ...)
{
va_list ap;
int i;
va_start(ap, fmt);
i = vasprintf(ret, fmt, ap);
va_end(ap);
if (i < 0 || *ret == NULL)
err(1, "asprintf");
return (i);
}