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"
11 #if !defined(HAVE_VASPRINTF)
12 /* CAW: compliant version of vasprintf */
13 static int vasprintf(char **buf, const char *fmt, va_list ap)
16 static char _T_emptybuffer = '\0';
17 #endif /* !defined(WIN32) */
21 if(!buf) { return -1; }
24 chars = _vscprintf(fmt, ap)+1;
25 #else /* !defined(WIN32) */
26 /* CAW: RAWR! We have to hope to god here that vsnprintf doesn't overwrite
27 our buffer like on some 64bit sun systems.... but hey, its time to move on */
28 chars = vsnprintf(&_T_emptybuffer, 0, fmt, ap)+1;
29 if(chars < 0) { chars *= -1; } /* CAW: old glibc versions have this problem */
30 #endif /* defined(WIN32) */
32 b = (char*)malloc(sizeof(char)*chars);
35 if((chars = vsprintf(b, fmt, ap)) < 0)
44 #endif /* !HAVE_VASPRINTF */
46 #endif /* __vasprintf_compat_h */