va_end(ap);
}
+static inline int
+util_vasprintf(char **ret, const char *format, va_list ap)
+{
+ va_list ap_copy;
+
+ /* Compute length of output string first */
+ va_copy(ap_copy, ap);
+ int r = util_vsnprintf(NULL, 0, format, ap);
+ va_end(ap_copy);
+
+ if (r < 0)
+ return -1;
+
+ *ret = (char *) malloc(r + 1);
+ if (!ret)
+ return -1;
+
+ /* Print to buffer */
+ return util_vsnprintf(*ret, r + 1, format, ap);
+}
+
static inline char *
util_strchr(const char *s, char c)
{
#define util_vsnprintf vsnprintf
#define util_snprintf snprintf
#define util_vsprintf vsprintf
+#define util_vasprintf vasprintf
#define util_sprintf sprintf
#define util_strchr strchr
#define util_strcmp strcmp