Minor cleanups

This commit is contained in:
Nils O. Selåsdal
2026-04-08 23:36:29 +02:00
parent 055338b1e9
commit 1b61b3c6d0
+5 -4
View File
@@ -73,14 +73,15 @@ void small_allocator_init(SmallAllocator* a, void* backing_store, size_t size)
{ {
// backing store must be aligned, otherwise all alignment guarantees are lies // backing store must be aligned, otherwise all alignment guarantees are lies
assert(((uintptr_t)backing_store & (ALIGNMENT - 1)) == 0); assert(((uintptr_t)backing_store & (ALIGNMENT - 1)) == 0);
assert(size >= sizeof(BlockHeader));
a->base = (uint8_t*)backing_store; a->base = backing_store;
a->size = size; a->size = size;
BlockHeader* first = (BlockHeader*)a->base; BlockHeader* first = backing_store;
size_t usable = ALIGN(size - sizeof(BlockHeader)); size_t usable = ALIGN(size - sizeof(BlockHeader));
block_set_free(first);
first->size_and_flags = usable | BLOCK_FREE; block_set_size(first, usable);
first->next = NULL; first->next = NULL;
first->prev = NULL; first->prev = NULL;