diff options
Diffstat (limited to 'xorg-server/os/xprintf.c')
-rw-r--r-- | xorg-server/os/xprintf.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c index 218c3c91f..ed2fa3d3b 100644 --- a/xorg-server/os/xprintf.c +++ b/xorg-server/os/xprintf.c @@ -76,7 +76,9 @@ # ifdef __va_copy
# define va_copy __va_copy
# else
+# ifndef _MSC_VER
# error "no working va_copy was found"
+# endif
# endif
#endif
@@ -97,18 +99,23 @@ Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va) return vasprintf(ret, format, va);
#else
int size;
+
+#ifdef _MSC_VER
+ size = vsnprintf(NULL, 0, format, va);
+#else
va_list va2;
va_copy(va2, va);
size = vsnprintf(NULL, 0, format, va2);
va_end(va2);
+#endif
*ret = malloc(size + 1);
if (*ret == NULL)
return -1;
vsnprintf(*ret, size + 1, format, va);
- ret[size] = 0;
+ (*ret)[size] = 0;
return size;
#endif
}
|