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

Function ArenaInit

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

Initialize the fields of an Arena

Source from the content-addressed store, hash-verified

261
262// Initialize the fields of an Arena
263static void ArenaInit(LowLevelAlloc::Arena *arena) {
264 if (arena->pagesize == 0) {
265 arena->pagesize = getpagesize();
266 // Round up block sizes to a power of two close to the header size.
267 arena->roundup = 16;
268 while (arena->roundup < sizeof (arena->freelist.header)) {
269 arena->roundup += arena->roundup;
270 }
271 // Don't allocate blocks less than twice the roundup size to avoid tiny
272 // free blocks.
273 arena->min_size = 2 * arena->roundup;
274 arena->freelist.header.size = 0;
275 arena->freelist.header.magic =
276 Magic(kMagicUnallocated, &arena->freelist.header);
277 arena->freelist.header.arena = arena;
278 arena->freelist.levels = 0;
279 memset(arena->freelist.next, 0, sizeof (arena->freelist.next));
280 arena->allocation_count = 0;
281 if (arena == &default_arena) {
282 // Default arena should be hooked, e.g. for heap-checker to trace
283 // pointer chains through objects in the default arena.
284 arena->flags = LowLevelAlloc::kCallMallocHook;
285 } else if (arena == &unhooked_async_sig_safe_arena) {
286 arena->flags = LowLevelAlloc::kAsyncSignalSafe;
287 } else {
288 arena->flags = 0; // other arenas' flags may be overridden by client,
289 // but unhooked_arena will have 0 in 'flags'.
290 }
291 }
292}
293
294// L < meta_data_arena->mu
295LowLevelAlloc::Arena *LowLevelAlloc::NewArena(int32 flags,

Callers 2

NewArenaMethod · 0.70
DoAllocWithArenaFunction · 0.70

Calls 2

MagicFunction · 0.70
getpagesizeFunction · 0.50

Tested by

no test coverage detected