diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-10-01 21:10:59 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-10-01 21:10:59 -0700 |
commit | 0faf882de6de6c1ec26aace9a9939914b40e7b89 (patch) | |
tree | adab03fc328e76476e9ee3218010888f4d81dbe4 /list.c | |
parent | 3b747cc5d2981c44ff517f64c355e76d70194f24 (diff) |
Use vasprintf(), if available, to implement dsprintf()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'list.c')
-rw-r--r-- | list.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -20,6 +20,8 @@ THE SOFTWARE. */ +#include "config.h" + #include <stdlib.h> #include <stdio.h> #include <stdarg.h> @@ -63,6 +65,13 @@ dsprintf(const char *f, ...) { va_list args; char *string; +#ifdef HAVE_VASPRINTF + va_start(args, f); + if (vasprintf(&string, f, args) == -1) + string = NULL; + va_end(args); + return string; +#else { int n, size = 20; while(1) { @@ -83,6 +92,7 @@ dsprintf(const char *f, ...) free(string); } } +#endif } |