diff options
Diffstat (limited to 'tests/un/allocs.c')
-rw-r--r-- | tests/un/allocs.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/tests/un/allocs.c b/tests/un/allocs.c index 3348e70..220c2c8 100644 --- a/tests/un/allocs.c +++ b/tests/un/allocs.c @@ -4,8 +4,10 @@ int main(void) { u64 i, size, *value; size = UN_KB(1); + un_alloc_temp_init(UN_KB(4)); + { // std - Allocator std = un_allocator_get_standard(); + Allocator std = un_alloc_std_get(); void *mem = un_memory_alloc(size, std); if (mem != NULL) { @@ -14,7 +16,7 @@ int main(void) { } { // temp - Allocator temp = un_allocator_get_temporary(); + Allocator temp = un_alloc_temp_get(); u8 *mem = (u8*) un_memory_alloc(size, temp); assert(mem != NULL); @@ -23,28 +25,29 @@ int main(void) { mem[i] = 0xAB; } - un_memory_destroy(&temp); + un_alloc_temp_reset(); } { // arena - Allocator arena = un_allocator_create_arena(size); + Allocator arena = un_alloc_arena_create(size * 8); - for (i = 0; i < 1000; i++) { - value = un_memory_alloc(8, arena); + for (i = 0; i < size; i++) { + value = un_memory_alloc_align(8, 8, arena); + assert(value != NULL); *value = 0xAC; } - un_memory_destroy(&arena); + un_alloc_arena_destroy(&arena); } - { // wrapper - Allocator wrapper = un_allocator_create_wrapper(un_allocator_create_arena(size)); - - for (i = 0; i < 1000; i++) { - value = un_memory_alloc(8, wrapper); - *value = 0xAC; - } - - un_memory_destroy(&wrapper); - } + // { // wrapper + // Allocator wrapper = un_alloc_create_wrapper(un_allocator_create_arena(size)); + // + // for (i = 0; i < 1000; i++) { + // value = un_memory_alloc(8, wrapper); + // *value = 0xAC; + // } + // + // un_memory_destroy(&wrapper); + // } } |