diff --git a/base/usr/include/stdio.h b/base/usr/include/stdio.h index f8ff0c9a..2317b993 100644 --- a/base/usr/include/stdio.h +++ b/base/usr/include/stdio.h @@ -34,6 +34,7 @@ extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * stream); extern int fileno(FILE * stream); extern int fflush(FILE * stream); +extern int asprintf(char ** ret, const char * fmt, ...); extern int vasprintf(char ** buf, const char *fmt, va_list args); extern int sprintf(char *buf, const char *fmt, ...); extern int fprintf(FILE *stream, const char *fmt, ...); diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c index 1547520a..1547c9b3 100644 --- a/libc/stdio/printf.c +++ b/libc/stdio/printf.c @@ -438,12 +438,19 @@ static int cb_asprintf(void * user, char c) { int vasprintf(char ** buf, const char * fmt, va_list args) { struct CBData data = {NULL,0,0}; - int out = xvasprintf(cb_asprintf, &data, fmt, args); + xvasprintf(cb_asprintf, &data, fmt, args); cb_asprintf(&data, '\0'); *buf = data.str; - return out; + return 0; } +int asprintf(char ** ret, const char * fmt, ...) { + va_list args; + va_start(args, fmt); + int out = vasprintf(ret,fmt,args); + va_end(args); + return out; +} /* Streams */