From 471b539bdbf658ff7924b7500f89fd237df8be9b Mon Sep 17 00:00:00 2001 From: bonmas14 Date: Sun, 3 Aug 2025 19:24:03 +0000 Subject: Reordering of stuff + plans --- tests/un/allocs.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/un/allocs.c (limited to 'tests/un/allocs.c') diff --git a/tests/un/allocs.c b/tests/un/allocs.c new file mode 100644 index 0000000..608d9f4 --- /dev/null +++ b/tests/un/allocs.c @@ -0,0 +1,39 @@ +#include + +int main(void) { + u64 i, size, *value; + size = UN_KB(1); + + { // std + Allocator std = un_allocator_get_standard(); + void *mem = un_memory_alloc(size, std); + + if (mem != NULL) { + un_memory_free(mem, std); + } + } + + { // temp + Allocator temp = un_allocator_get_temporary(); + + u8 *mem = (u8*) un_memory_alloc(size, temp); + assert(mem != NULL); + + for (i = 0; i < size; i++) { + mem[i] = 0xAB; + } + + un_memory_destroy(&temp); + } + + { // arena + Allocator arena = un_allocator_create_arena(size); + + for (i = 0; i < 1000; i++) { + value = un_memory_alloc(8, arena); + *value = 0xAC; + } + + un_memory_destroy(&arena); + } +} -- cgit v1.2.3-70-g09d2