Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmxmlrpc / casprintf.c
blob1fcc7741f0a5087fada70e7e433169f5d9a32bd1
1 #define _GNU_SOURCE
2 #include <stdarg.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 #include "xmlrpc_config.h" /* For HAVE_ASPRINTF */
7 #include "casprintf.h"
9 void GNU_PRINTF_ATTR(2,3)
10 casprintf(const char ** const retvalP, const char * const fmt, ...) {
12 char *retval;
14 va_list varargs; /* mysterious structure used by variable arg facility */
16 va_start(varargs, fmt); /* start up the mysterious variable arg facility */
18 #if HAVE_ASPRINTF
19 vasprintf(&retval, fmt, varargs);
20 #else
21 retval = malloc(8192);
22 vsnprintf(retval, 8192, fmt, varargs);
23 #endif
24 *retvalP = retval;
29 void
30 strfree(const char * const string) {
31 free((void *)string);