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

Function xmlMemRealloc

ThirdParty/libxml2/vtklibxml2/xmlmemory.c:154–193  ·  view source on GitHub ↗

* xmlMemRealloc: * @ptr: the initial memory block pointer * @size: an int specifying the size in byte to allocate. * * a realloc() 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

152 * Returns a pointer to the allocated area or NULL in case of lack of memory.
153 */
154void *
155xmlMemRealloc(void *ptr, size_t size) {
156 MEMHDR *p, *tmp;
157 size_t oldSize;
158
159 if (ptr == NULL)
160 return(xmlMemMalloc(size));
161
162 xmlInitParser();
163
164 if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
165 fprintf(stderr, "xmlMemRealloc: Unsigned overflow\n");
166 return(NULL);
167 }
168
169 p = CLIENT_2_HDR(ptr);
170 if (p->mh_tag != MEMTAG) {
171 fprintf(stderr, "xmlMemRealloc: Tag error\n");
172 return(NULL);
173 }
174 oldSize = p->mh_size;
175 p->mh_tag = ~MEMTAG;
176
177 tmp = (MEMHDR *) realloc(p, RESERVE_SIZE + size);
178 if (!tmp) {
179 p->mh_tag = MEMTAG;
180 fprintf(stderr, "xmlMemRealloc: Out of memory\n");
181 return(NULL);
182 }
183 p = tmp;
184 p->mh_tag = MEMTAG;
185 p->mh_size = size;
186
187 xmlMutexLock(&xmlMemMutex);
188 debugMemSize -= oldSize;
189 debugMemSize += size;
190 xmlMutexUnlock(&xmlMemMutex);
191
192 return(HDR_2_CLIENT(p));
193}
194
195/**
196 * xmlMemFree:

Callers 2

xmlReallocLocFunction · 0.85
myReallocFuncFunction · 0.85

Calls 5

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

Tested by

no test coverage detected