void * xmlMemMalloc(size_t size) { return(xmlMallocLoc(size, "none", 0)); }
void * xmlReallocLoc(void *ptr,size_t size, const char * file, int line) { MEMHDR *p; unsigned long number; #ifdef DEBUG_MEMORY size_t oldsize; #endif if (ptr == NULL) return(xmlMallocLoc(size, file, line)); if (!xmlMemInitialized) xmlInitMemory(); TEST_POINT p = CLIENT_2_HDR(ptr); number = p->mh_number; if (xmlMemStopAtBlock == number) xmlMallocBreakpoint(); if (p->mh_tag != MEMTAG) { Mem_Tag_Err(p); goto error; } p->mh_tag = ~MEMTAG; xmlMutexLock(xmlMemMutex); debugMemSize -= p->mh_size; debugMemBlocks--; #ifdef DEBUG_MEMORY oldsize = p->mh_size; #endif #ifdef MEM_LIST debugmem_list_delete(p); #endif xmlMutexUnlock(xmlMemMutex); p = (MEMHDR *) realloc(p,RESERVE_SIZE+size); if (!p) { goto error; } if (xmlMemTraceBlockAt == ptr) { xmlGenericError(xmlGenericErrorContext, "%p : Realloced(%d -> %d) Ok\n", xmlMemTraceBlockAt, p->mh_size, size); xmlMallocBreakpoint(); } p->mh_tag = MEMTAG; p->mh_number = number; p->mh_type = REALLOC_TYPE; p->mh_size = size; p->mh_file = file; p->mh_line = line; xmlMutexLock(xmlMemMutex); debugMemSize += size; debugMemBlocks++; if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; #ifdef MEM_LIST debugmem_list_add(p); #endif xmlMutexUnlock(xmlMemMutex); TEST_POINT #ifdef DEBUG_MEMORY xmlGenericError(xmlGenericErrorContext, "Realloced(%d to %d) Ok\n", oldsize, size); #endif return(HDR_2_CLIENT(p)); error: return(NULL); }
void * xmlMemMalloc(unsigned int size) { return(xmlMallocLoc(size, "none", 0)); }