Add support for initialising arena with backing buffer

This commit is contained in:
2026-01-03 18:36:30 +00:00
parent 83b879a180
commit 326265722e
12 changed files with 195 additions and 61 deletions

View File

@@ -15,3 +15,19 @@ TestFuncResult test_arena_allocator(void) {
return wapp_tester_result(result);
}
TestFuncResult test_arena_allocator_with_buffer(void) {
u8 buffer[KiB(4)] = {0};
Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
allocator.alloc_aligned != NULL &&
allocator.realloc != NULL && allocator.realloc_aligned != NULL &&
allocator.free == NULL;
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
result = result && (ptr != NULL);
wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result);
}

View File

@@ -15,3 +15,19 @@ TestFuncResult test_arena_allocator(void) {
return wapp_tester_result(result);
}
TestFuncResult test_arena_allocator_with_buffer(void) {
u8 buffer[KiB(4)] = {0};
Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
allocator.alloc_aligned != NULL &&
allocator.realloc != NULL && allocator.realloc_aligned != NULL &&
allocator.free == NULL;
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
result = result && (ptr != NULL);
wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result);
}

View File

@@ -4,5 +4,6 @@
#include "wapp.h"
TestFuncResult test_arena_allocator(void);
TestFuncResult test_arena_allocator_with_buffer(void);
#endif // !TEST_ALLOCATOR_H