PageAllocatorInit
Description
Initialize a PageAllocator with default settings (alignment = 1, the natural page-grain alignment of mmap/VirtualAlloc). Use as a designated-initializer:
PageAllocator page = PageAllocatorInit(); Vec(int) v = VecInit(&page);
Usage example (Cross-references)
Usage examples (Cross-references)
static bool test_basic_alloc_and_free(void) {
PageAllocator alloc = PageAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
void *ptr = AllocatorAlloc(alloc_base, 128, true);
static bool test_realloc_grow_then_shrink(void) {
PageAllocator alloc = PageAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
size page = PageAllocatorPageSize(&alloc);
static bool test_vec_with_page_allocator(void) {
PageAllocator alloc = PageAllocatorInit();
typedef Vec(int) IntVec;
IntVec v = VecInit(&alloc);- In
Heap.h:96:
.bins = {0}, \
.chunks_head = NULL, \
.page = PageAllocatorInit() \
})- In
Heap.h:116:
.bins = {0}, \
.chunks_head = NULL, \
.page = PageAllocatorInit() \
})- In
Arena.h:75:
.last_ptr = NULL, \
.last_size = 0, \
.page = PageAllocatorInit() \
})- In
Arena.h:92:
.last_ptr = NULL, \
.last_size = 0, \
.page = PageAllocatorInit() \
})- In
Slab.h:72:
.slot_size = (slot_size_bytes), \
.slots_per_chunk = MISRA_SLAB_DEFAULT_CHUNK_SLOTS, \
.page = PageAllocatorInit() \
})- In
Slab.h:93:
.slot_size = (slot_size_bytes), \
.slots_per_chunk = MISRA_SLAB_DEFAULT_CHUNK_SLOTS, \
.page = PageAllocatorInit() \
})
Last updated on