Working on simplifying configurable allocation scheme
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user