diff options
Diffstat (limited to 'source3/lib/snprintf.c')
-rw-r--r-- | source3/lib/snprintf.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/source3/lib/snprintf.c b/source3/lib/snprintf.c index ce7c4a68f5..3edb50c6ad 100644 --- a/source3/lib/snprintf.c +++ b/source3/lib/snprintf.c @@ -735,23 +735,31 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) #endif - -#ifndef HAVE_ASPRINTF - int asprintf(char **ptr, const char *format, ...) +#ifndef HAVE_VASPRINTF + int vasprintf(char **ptr, const char *format, va_list ap) { - va_list ap; int ret; - va_start(ap, format); ret = vsnprintf(NULL, 0, format, ap); - va_end(ap); - if (ret <= 0) return ret; - - va_start(ap, format); + (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; ret = vsnprintf(*ptr, ret+1, format, ap); + + return ret; +} +#endif + + +#ifndef HAVE_ASPRINTF + int asprintf(char **ptr, const char *format, ...) +{ + va_list ap; + int ret; + + va_start(ap, format); + ret = vasprintf(ptr, format, ap); va_end(ap); return ret; |