|
|
|
@ -60,14 +60,12 @@ struct MemoryStruct {
|
|
|
|
|
size_t size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* There might be a realloc() out there that doesn't like reallocing
|
|
|
|
|
* NULL pointers, so we take care of it here
|
|
|
|
|
*/
|
|
|
|
|
static void *myrealloc(void *ptr, size_t size)
|
|
|
|
|
{
|
|
|
|
|
/* There might be a realloc() out there that doesn't like reallocing
|
|
|
|
|
NULL pointers, so we take care of it here */
|
|
|
|
|
if (ptr)
|
|
|
|
|
return ast_realloc(ptr, size);
|
|
|
|
|
else
|
|
|
|
|
return ast_malloc(size);
|
|
|
|
|
return (ptr ? ast_realloc(ptr, size) : ast_malloc(size));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
|
|
|
|
@ -75,12 +73,12 @@ static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *da
|
|
|
|
|
register int realsize = size * nmemb;
|
|
|
|
|
struct MemoryStruct *mem = (struct MemoryStruct *)data;
|
|
|
|
|
|
|
|
|
|
mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
|
|
|
|
|
if (mem->memory) {
|
|
|
|
|
if ((mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1))) {
|
|
|
|
|
memcpy(&(mem->memory[mem->size]), ptr, realsize);
|
|
|
|
|
mem->size += realsize;
|
|
|
|
|
mem->memory[mem->size] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return realsize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|