MCPcopy Create free account
hub / github.com/beefytech/Beef / Free

Method Free

BeefRT/gperftools/src/base/low_level_alloc.cc:414–430  ·  view source on GitHub ↗

Frees storage allocated by LowLevelAlloc::Alloc(). L < arena->mu

Source from the content-addressed store, hash-verified

412// Frees storage allocated by LowLevelAlloc::Alloc().
413// L < arena->mu
414void LowLevelAlloc::Free(void *v) {
415 if (v != 0) {
416 AllocList *f = reinterpret_cast<AllocList *>(
417 reinterpret_cast<char *>(v) - sizeof (f->header));
418 RAW_CHECK(f->header.magic == Magic(kMagicAllocated, &f->header),
419 "bad magic number in Free()");
420 LowLevelAlloc::Arena *arena = f->header.arena;
421 if ((arena->flags & kCallMallocHook) != 0) {
422 MallocHook::InvokeDeleteHook(v);
423 }
424 ArenaLock section(arena);
425 AddToFreelist(v, arena);
426 RAW_CHECK(arena->allocation_count > 0, "nothing in arena to free");
427 arena->allocation_count--;
428 section.Leave();
429 }
430}
431
432// allocates and returns a block of size bytes, to be freed with Free()
433// L < arena->mu

Callers

nothing calls this directly

Calls 3

MagicFunction · 0.70
AddToFreelistFunction · 0.70
LeaveMethod · 0.45

Tested by

no test coverage detected