MCPcopy Create free account
hub / github.com/F-Stack/f-stack / memguard_realloc

Function memguard_realloc

freebsd/vm/memguard.c:417–437  ·  view source on GitHub ↗

* Re-allocate an allocation that was originally guarded. */

Source from the content-addressed store, hash-verified

415 * Re-allocate an allocation that was originally guarded.
416 */
417void *
418memguard_realloc(void *addr, unsigned long size, struct malloc_type *mtp,
419 int flags)
420{
421 void *newaddr;
422 u_long old_size;
423
424 /*
425 * Allocate the new block. Force the allocation to be guarded
426 * as the original may have been guarded through random
427 * chance, and that should be preserved.
428 */
429 if ((newaddr = memguard_alloc(size, flags)) == NULL)
430 return (NULL);
431
432 /* Copy over original contents. */
433 old_size = *v2sizep(trunc_page((uintptr_t)addr));
434 bcopy(addr, newaddr, min(size, old_size));
435 memguard_free(addr);
436 return (newaddr);
437}
438
439static int
440memguard_cmp(unsigned long size)

Callers 1

reallocFunction · 0.85

Calls 4

memguard_allocFunction · 0.85
v2sizepFunction · 0.85
minFunction · 0.85
memguard_freeFunction · 0.85

Tested by

no test coverage detected