util: add asprintf() wrapper for MSVC
authorEric Engestrom <eric.engestrom@intel.com>
Fri, 19 Jul 2019 21:09:34 +0000 (22:09 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Tue, 23 Jul 2019 07:57:27 +0000 (08:57 +0100)
Fixes: 856e84083eee9b22408a ("mesa/st: add sampler uniforms")
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/util/u_string.h

index 499894b9f9477665dcabd9d31b7e6859e395da3b..e7163927667517b51e30aaa7c1300467842f0452 100644 (file)
@@ -98,6 +98,18 @@ util_vasprintf(char **ret, const char *format, va_list ap)
    return vsnprintf(*ret, r + 1, format, ap);
 }
 
+#define asprintf util_asprintf
+static inline char *
+util_asprintf(const char *fmt, ...)
+{
+   char *ptr;
+   va_list args;
+   va_start(args, fmt);
+   if (vasprintf(&ptr, fmt, args) == -1)
+      ptr = NULL;
+   va_end(args);
+   return ptr;
+}
 
 #define strcasecmp stricmp
 #define strdup _strdup