diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2012-11-24 10:42:47 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2012-11-24 10:42:47 +0000 |
commit | 7fefde54b6b0d7d42bd6ca806e843342c3c970c3 (patch) | |
tree | 3d544b45525a0df57910fb21132015edf9b1e530 /usr.sbin/ldomctl/util.c | |
parent | 989d2a208848db2cd73c7b151dc76842d732d600 (diff) |
Add xasprintf.
Diffstat (limited to 'usr.sbin/ldomctl/util.c')
-rw-r--r-- | usr.sbin/ldomctl/util.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.sbin/ldomctl/util.c b/usr.sbin/ldomctl/util.c index e2c3213b53d..89437f72ae3 100644 --- a/usr.sbin/ldomctl/util.c +++ b/usr.sbin/ldomctl/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.2 2012/10/27 18:50:43 kettenis Exp $ */ +/* $OpenBSD: util.c,v 1.3 2012/11/24 10:42:46 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -17,6 +17,8 @@ */ #include <err.h> +#include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,3 +57,17 @@ xstrdup(const char *s) err(1, NULL); return p; } + +int +xasprintf(char **str, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret = vasprintf(str, fmt, ap); + va_end(ap); + if (ret == -1) + err(1, NULL); + return ret; +} |