mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
merged new xmlrpc-c revision 1472 from https://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/trunk
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8545 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -21,12 +21,12 @@ simpleVasprintf(char ** const retvalP,
|
||||
result = malloc(initialSize);
|
||||
if (result != NULL) {
|
||||
size_t bytesNeeded;
|
||||
bytesNeeded = vsnprintf(result, initialSize, fmt, varargs);
|
||||
bytesNeeded = XMLRPC_VSNPRINTF(result, initialSize, fmt, varargs);
|
||||
if (bytesNeeded > initialSize) {
|
||||
free(result);
|
||||
result = malloc(bytesNeeded);
|
||||
if (result != NULL)
|
||||
vsnprintf(result, bytesNeeded, fmt, varargs);
|
||||
XMLRPC_VSNPRINTF(result, bytesNeeded, fmt, varargs);
|
||||
} else if (bytesNeeded == initialSize) {
|
||||
if (result[initialSize-1] != '\0') {
|
||||
/* This is one of those old systems where vsnprintf()
|
||||
@@ -46,23 +46,31 @@ simpleVasprintf(char ** const retvalP,
|
||||
|
||||
|
||||
|
||||
const char * const strsol = "[Insufficient memory to build string]";
|
||||
|
||||
|
||||
|
||||
void
|
||||
cvasprintf(const char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs) {
|
||||
|
||||
char * retval;
|
||||
char * string;
|
||||
|
||||
#if HAVE_ASPRINTF
|
||||
vasprintf(&retval, fmt, varargs);
|
||||
vasprintf(&string, fmt, varargs);
|
||||
#else
|
||||
simpleVasprintf(&retval, fmt, varargs);
|
||||
simpleVasprintf(&string, fmt, varargs);
|
||||
#endif
|
||||
|
||||
*retvalP = retval;
|
||||
if (string == NULL)
|
||||
*retvalP = strsol;
|
||||
else
|
||||
*retvalP = string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GNU_PRINTF_ATTR(2,3)
|
||||
casprintf(const char ** const retvalP, const char * const fmt, ...) {
|
||||
|
||||
@@ -79,5 +87,7 @@ casprintf(const char ** const retvalP, const char * const fmt, ...) {
|
||||
|
||||
void
|
||||
strfree(const char * const string) {
|
||||
free((void *)string);
|
||||
|
||||
if (string != strsol)
|
||||
free((void *)string);
|
||||
}
|
||||
|
Reference in New Issue
Block a user