summary refs log tree commit diff
path: root/xmalloc.c
diff options
context:
space:
mode:
authorokan <okan>2012-11-28 14:32:44 +0000
committerokan <okan>2012-11-28 14:32:44 +0000
commit3e151f8c764a5f1116fae3bea87f3d4474dc686a (patch)
treea20cabba3a963cb2d272377b2a1ca2b2e9a801e2 /xmalloc.c
parent2b9d921edaa665f896cf29bf6ba332c6ac11dd21 (diff)
downloadcwm-3e151f8c764a5f1116fae3bea87f3d4474dc686a.tar.gz
cwm-3e151f8c764a5f1116fae3bea87f3d4474dc686a.tar.xz
cwm-3e151f8c764a5f1116fae3bea87f3d4474dc686a.zip
add xasprintf() for upcoming changes.
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/xmalloc.c b/xmalloc.c
index d0697fa..0480c73 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -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);
+}