diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2012-11-28 14:32:45 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2012-11-28 14:32:45 +0000 |
commit | 1506f47dd4a8236c116c615d711d7cc91ed89a46 (patch) | |
tree | ce4c1e32ea518e68b5c059f769f92f2182bbe08b /app/cwm/xmalloc.c | |
parent | 28706ebf01921d838d4ce9d01fcf7969aedc5eaa (diff) |
add xasprintf() for upcoming changes.
Diffstat (limited to 'app/cwm/xmalloc.c')
-rw-r--r-- | app/cwm/xmalloc.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/cwm/xmalloc.c b/app/cwm/xmalloc.c index 8e9d22ab2..c278e721f 100644 --- a/app/cwm/xmalloc.c +++ b/app/cwm/xmalloc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xmalloc.c,v 1.10 2012/11/16 14:15:48 okan Exp $ + * $OpenBSD: xmalloc.c,v 1.11 2012/11/28 14:32:44 okan Exp $ */ #include <sys/param.h> @@ -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); +} |