mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 09:36:46 +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:
@@ -50,14 +50,28 @@ static __inline__ void
|
||||
reallocProduct(void ** const blockP,
|
||||
unsigned int const factor1,
|
||||
unsigned int const factor2) {
|
||||
|
||||
void * const oldBlockP = *blockP;
|
||||
|
||||
void * newBlockP;
|
||||
|
||||
if (UINT_MAX / factor2 < factor1)
|
||||
*blockP = NULL;
|
||||
newBlockP = NULL;
|
||||
else
|
||||
*blockP = realloc(*blockP, factor1 * factor2);
|
||||
newBlockP = realloc(oldBlockP, factor1 * factor2);
|
||||
|
||||
if (newBlockP)
|
||||
*blockP = newBlockP;
|
||||
else {
|
||||
free(oldBlockP);
|
||||
*blockP = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* IMPLEMENTATION NOTE: There are huge strict aliasing pitfalls here
|
||||
if you cast pointers, e.g. (void **)
|
||||
*/
|
||||
|
||||
#define MALLOCARRAY(arrayName, nElements) do { \
|
||||
void * array; \
|
||||
@@ -65,8 +79,11 @@ reallocProduct(void ** const blockP,
|
||||
arrayName = array; \
|
||||
} while (0)
|
||||
|
||||
#define REALLOCARRAY(arrayName, nElements) \
|
||||
reallocProduct((void **)&arrayName, nElements, sizeof(arrayName[0]))
|
||||
#define REALLOCARRAY(arrayName, nElements) do { \
|
||||
void * array = arrayName; \
|
||||
reallocProduct(&array, nElements, sizeof(arrayName[0])); \
|
||||
arrayName = array; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define MALLOCARRAY_NOFAIL(arrayName, nElements) \
|
||||
|
Reference in New Issue
Block a user