MCPcopy Create free account
hub / github.com/crownengine/crown / allocate

Method allocate

src/core/memory/pool_allocator.cpp:66–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void *PoolAllocator::allocate(u32 size, u32 align)
67{
68 CE_ENSURE(size <= _block_size);
69 CE_ENSURE(align <= _block_align);
70 CE_ENSURE(is_power_of_2(align));
71 CE_UNUSED_2(size, align);
72
73 if (CE_UNLIKELY(_freelist == NULL)) {
74 PoolHeader *new_pool = make_pool(_backing, _num_blocks, _block_size, _block_align);
75 new_pool->next = _start;
76 _start = new_pool;
77 _freelist = new_pool->first_block;
78 }
79
80 uintptr_t next_free = *(uintptr_t *)_freelist;
81 void *data = _freelist;
82 _freelist = (void *)next_free;
83
84 return data;
85}
86
87void PoolAllocator::deallocate(void *data)
88{

Callers 4

test_memoryFunction · 0.45
make_poolFunction · 0.45
callstackFunction · 0.45
crashFunction · 0.45

Calls 2

is_power_of_2Function · 0.85
make_poolFunction · 0.85

Tested by 1

test_memoryFunction · 0.36