Working on simplifying configurable allocation scheme

This commit is contained in:
Krzosa Karol
2023-01-01 12:40:58 +01:00
parent 8c0a8bf72b
commit c5539276ae
18 changed files with 169 additions and 347 deletions

View File

@@ -31,6 +31,15 @@ static void *scratch_arena_push_size(Scratch_Arena *arena, size_t size) {
return (void *)result;
}
static Scratch_Arena *make_scratch_arena(void *buff, size_t size) {
Scratch_Arena *scratch = (Scratch_Arena *)buff;
scratch->len = 0;
scratch->cap = size - sizeof(Scratch_Arena);
scratch->allocate = (Allocator::Allocate *)scratch_arena_push_size;
scratch->deallocate = deallocate_stub;
return scratch;
}
static Scratch_Arena *allocate_scratch_arena(Allocator *allocator, size_t size_without_members) {
Scratch_Arena *scratch = (Scratch_Arena *)allocate_size(allocator, size_without_members + sizeof(Scratch_Arena), false);
scratch->cap = size_without_members;