aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils.h
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-06-08 23:31:18 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-06-15 06:43:30 +0200
commita697a21927bddb091ba1a6d88c4db01ef2f58092 (patch)
treeda55b583dba1b28e1c8c2ddc11b799ce6c3324d8 /utils.h
parent4ca1ddef1c928da98f6e7a59afda231cda75a036 (diff)
downloadsparse-dev-a697a21927bddb091ba1a6d88c4db01ef2f58092.tar.gz
utils: add xasprintf() & xvasprintf()
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/utils.h b/utils.h
index 38749be2..7bd14f46 100644
--- a/utils.h
+++ b/utils.h
@@ -6,6 +6,7 @@
// -----------------------
#include <stddef.h>
+#include <stdarg.h>
///
// duplicate a memory buffer in a newly allocated buffer.
@@ -22,4 +23,21 @@ void *xmemdup(const void *src, size_t len);
// :func:`__alloc_bytes()`.
char *xstrdup(const char *src);
+///
+// printf to allocated string
+// @fmt: the format followed by its arguments.
+// @return: the allocated & formatted string.
+// This function is similar to asprintf() but the resulting string
+// is allocated with __alloc_bytes().
+char *xasprintf(const char *fmt, ...);
+
+///
+// vprintf to allocated string
+// @fmt: the format
+// @ap: the variadic arguments
+// @return: the allocated & formatted string.
+// This function is similar to asprintf() but the resulting string
+// is allocated with __alloc_bytes().
+char *xvasprintf(const char *fmt, va_list ap);
+
#endif