summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--glcpp.h3
-rw-r--r--xtalloc.c18
2 files changed, 21 insertions, 0 deletions
diff --git a/glcpp.h b/glcpp.h
index 2e93cb981d..048a9be76b 100644
--- a/glcpp.h
+++ b/glcpp.h
@@ -149,4 +149,7 @@ xtalloc_strdup (const void *t, const char *p);
char *
xtalloc_strndup (const void *t, const char *p, size_t n);
+char *
+xtalloc_asprintf (const void *t, const char *fmt, ...);
+
#endif
diff --git a/xtalloc.c b/xtalloc.c
index d9893ae889..e52d12ac6b 100644
--- a/xtalloc.c
+++ b/xtalloc.c
@@ -64,3 +64,21 @@ xtalloc_strndup (const void *t, const char *p, size_t n)
return ret;
}
+
+char *
+xtalloc_asprintf (const void *t, const char *fmt, ...)
+{
+ va_list ap;
+ char *ret;
+
+ va_start(ap, fmt);
+
+ ret = talloc_vasprintf(t, fmt, ap);
+ if (ret == NULL) {
+ fprintf (stderr, "Out of memory.\n");
+ exit (1);
+ }
+
+ va_end(ap);
+ return ret;
+}