diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-08 23:31:18 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-15 06:43:30 +0200 |
| commit | a697a21927bddb091ba1a6d88c4db01ef2f58092 (patch) | |
| tree | da55b583dba1b28e1c8c2ddc11b799ce6c3324d8 /utils.h | |
| parent | 4ca1ddef1c928da98f6e7a59afda231cda75a036 (diff) | |
| download | sparse-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.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |
