MCPcopy Create free account
hub / github.com/Singular/Singular / omDoRealloc

Function omDoRealloc

omalloc/om_Alloc.c:229–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227#endif
228
229void* omDoRealloc(void* old_addr, size_t new_size, int flag)
230{
231 void* new_addr;
232
233 if (!omIsBinPageAddr(old_addr) && new_size > OM_MAX_BLOCK_SIZE)
234 {
235 if (DO_ZERO(flag))
236 return omRealloc0Large(old_addr, new_size);
237 else
238 return omReallocLarge(old_addr, new_size);
239 }
240 else
241 {
242 size_t old_size = omSizeOfAddr(old_addr);
243 size_t min_size;
244
245 omAssume(OM_IS_ALIGNED(old_addr));
246
247#ifdef OM_ALIGNMENT_NEEDS_WORK
248 if (flag & 2)
249 __omTypeAllocAligned(void*, new_addr, new_size);
250 else
251#endif
252 __omTypeAlloc(void*, new_addr, new_size);
253
254 new_size = omSizeOfAddr(new_addr);
255 min_size = (old_size < new_size ? old_size : new_size);
256 omMemcpyW(new_addr, old_addr, min_size >> LOG_SIZEOF_LONG);
257
258 if (DO_ZERO(flag) && (new_size > old_size))
259 omMemsetW((char*) new_addr + min_size, 0, (new_size - old_size) >> LOG_SIZEOF_LONG);
260
261 __omFreeSize(old_addr, old_size);
262
263 return new_addr;
264 }
265}
266#endif
267#endif /* OM_ALLOC_C */

Callers

nothing calls this directly

Calls 3

omRealloc0LargeFunction · 0.85
omReallocLargeFunction · 0.85
omSizeOfAddrFunction · 0.85

Tested by

no test coverage detected