MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlMemMalloc

Function xmlMemMalloc

ThirdParty/libxml2/vtklibxml2/xmlmemory.c:99–125  ·  view source on GitHub ↗

* xmlMemMalloc: * @size: an int specifying the size in byte to allocate. * * a malloc() equivalent, with logging of the allocation info. * * Returns a pointer to the allocated area or NULL in case of lack of memory. */

Source from the content-addressed store, hash-verified

97 * Returns a pointer to the allocated area or NULL in case of lack of memory.
98 */
99void *
100xmlMemMalloc(size_t size)
101{
102 MEMHDR *p;
103
104 xmlInitParser();
105
106 if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
107 fprintf(stderr, "xmlMemMalloc: Unsigned overflow\n");
108 return(NULL);
109 }
110
111 p = (MEMHDR *) malloc(RESERVE_SIZE + size);
112 if (!p) {
113 fprintf(stderr, "xmlMemMalloc: Out of memory\n");
114 return(NULL);
115 }
116 p->mh_tag = MEMTAG;
117 p->mh_size = size;
118
119 xmlMutexLock(&xmlMemMutex);
120 debugMemSize += size;
121 debugMemBlocks++;
122 xmlMutexUnlock(&xmlMemMutex);
123
124 return(HDR_2_CLIENT(p));
125}
126
127/**
128 * xmlReallocLoc:

Callers 4

xmlMallocLocFunction · 0.85
xmlMallocAtomicLocFunction · 0.85
xmlMemReallocFunction · 0.85
myMallocFuncFunction · 0.85

Calls 4

xmlInitParserFunction · 0.85
fprintfFunction · 0.85
xmlMutexLockFunction · 0.85
xmlMutexUnlockFunction · 0.85

Tested by

no test coverage detected