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

Function AddToFreelist

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

Adds block at location "v" to the free list L >= arena->mu

Source from the content-addressed store, hash-verified

395// Adds block at location "v" to the free list
396// L >= arena->mu
397static void AddToFreelist(void *v, LowLevelAlloc::Arena *arena) {
398 AllocList *f = reinterpret_cast<AllocList *>(
399 reinterpret_cast<char *>(v) - sizeof (f->header));
400 RAW_CHECK(f->header.magic == Magic(kMagicAllocated, &f->header),
401 "bad magic number in AddToFreelist()");
402 RAW_CHECK(f->header.arena == arena,
403 "bad arena pointer in AddToFreelist()");
404 f->levels = LLA_SkiplistLevels(f->header.size, arena->min_size, true);
405 AllocList *prev[kMaxLevel];
406 LLA_SkiplistInsert(&arena->freelist, f, prev);
407 f->header.magic = Magic(kMagicUnallocated, &f->header);
408 Coalesce(f); // maybe coalesce with successor
409 Coalesce(prev[0]); // maybe coalesce with predecessor
410}
411
412// Frees storage allocated by LowLevelAlloc::Alloc().
413// L < arena->mu

Callers 2

FreeMethod · 0.70
DoAllocWithArenaFunction · 0.70

Calls 4

MagicFunction · 0.70
LLA_SkiplistLevelsFunction · 0.70
LLA_SkiplistInsertFunction · 0.70
CoalesceFunction · 0.70

Tested by

no test coverage detected