From: Eric Engestrom Date: Tue, 23 Jul 2019 09:52:16 +0000 (+0100) Subject: util: fix asprintf() fallback X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7797823afa1890e22774089f79634f631c4d0cb9;p=mesa.git util: fix asprintf() fallback Fixes: 9607d499dcdd09160b13 ("util: add asprintf() wrapper for MSVC") Signed-off-by: Eric Engestrom Reviewed-by: Alyssa Rosenzweig --- diff --git a/src/util/u_string.h b/src/util/u_string.h index e7163927667..5fea8f17e73 100644 --- a/src/util/u_string.h +++ b/src/util/u_string.h @@ -99,16 +99,15 @@ util_vasprintf(char **ret, const char *format, va_list ap) } #define asprintf util_asprintf -static inline char * -util_asprintf(const char *fmt, ...) +static inline int +util_asprintf(char **str, const char *fmt, ...) { - char *ptr; + int ret; va_list args; va_start(args, fmt); - if (vasprintf(&ptr, fmt, args) == -1) - ptr = NULL; + ret = vasprintf(str, fmt, args); va_end(args); - return ptr; + return ret; } #define strcasecmp stricmp