util: fix asprintf() fallback
authorEric Engestrom <eric.engestrom@intel.com>
Tue, 23 Jul 2019 09:52:16 +0000 (10:52 +0100)
committerEric Engestrom <eric@engestrom.ch>
Tue, 23 Jul 2019 14:59:07 +0000 (14:59 +0000)
Fixes: 9607d499dcdd09160b13 ("util: add asprintf() wrapper for MSVC")
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/util/u_string.h

index e7163927667517b51e30aaa7c1300467842f0452..5fea8f17e737409f0736191a351a83cc1a051802 100644 (file)
@@ -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