summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Engestrom <[email protected]>2019-07-23 10:52:16 +0100
committerEric Engestrom <[email protected]>2019-07-23 14:59:07 +0000
commit7797823afa1890e22774089f79634f631c4d0cb9 (patch)
tree85d57de00452114f00c3ad309d4a646fb88e3899
parent22c7738520e2642a7f297d9b85f3dbfba37ca862 (diff)
util: fix asprintf() fallback
Fixes: 9607d499dcdd09160b13 ("util: add asprintf() wrapper for MSVC") Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r--src/util/u_string.h11
1 files changed, 5 insertions, 6 deletions
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