1 #ifndef __vasprintf_compat_h
2 #define __vasprintf_compat_h
6 * @brief Do not use, json-c internal, may be changed or removed at any time.
9 #include "snprintf_compat.h"
13 #endif /* !defined(WIN32) */
17 #if !defined(HAVE_VASPRINTF)
18 /* CAW: compliant version of vasprintf */
19 static int vasprintf(char **buf, const char *fmt, va_list ap)
22 static char _T_emptybuffer = '\0';
24 #endif /* !defined(WIN32) */
34 chars = _vscprintf(fmt, ap);
35 #else /* !defined(WIN32) */
36 /* CAW: RAWR! We have to hope to god here that vsnprintf doesn't overwrite
37 * our buffer like on some 64bit sun systems... but hey, it's time to move on
40 chars = vsnprintf(&_T_emptybuffer, 0, fmt, ap2);
42 #endif /* defined(WIN32) */
43 if (chars < 0 || (size_t)chars + 1 > SIZE_MAX / sizeof(char))
48 b = (char *)malloc(sizeof(char) * ((size_t)chars + 1));
54 if ((chars = vsprintf(b, fmt, ap)) < 0)
65 #endif /* !HAVE_VASPRINTF */
67 #endif /* __vasprintf_compat_h */