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 | |
parent | 989d2a208848db2cd73c7b151dc76842d732d600 (diff) |
Add xasprintf.
Diffstat (limited to 'usr.sbin/ldomctl')
-rw-r--r-- | usr.sbin/ldomctl/util.c | 18 | ||||
-rw-r--r-- | usr.sbin/ldomctl/util.h | 3 |
2 files changed, 19 insertions, 2 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; +} diff --git a/usr.sbin/ldomctl/util.h b/usr.sbin/ldomctl/util.h index 51b6681480d..9f93388e76d 100644 --- a/usr.sbin/ldomctl/util.h +++ b/usr.sbin/ldomctl/util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: util.h,v 1.2 2012/10/27 18:50:43 kettenis Exp $ */ +/* $OpenBSD: util.h,v 1.3 2012/11/24 10:42:46 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -24,6 +24,7 @@ extern int debug; void *xmalloc(size_t); void *xzalloc(size_t); char *xstrdup(const char *); +int xasprintf(char**, const char *, ...); #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) |