diff options
author | bonmas14 <bonmas14@gmail.com> | 2025-08-02 23:20:37 +0000 |
---|---|---|
committer | bonmas14 <bonmas14@gmail.com> | 2025-08-02 23:20:37 +0000 |
commit | 1cf89852f951b59b89f2a8bd7b54a0b0b74d439c (patch) | |
tree | 884af08903beba5f0e1e8435df4a1c7015270487 /tests/allocs.c | |
download | ungrateful-1cf89852f951b59b89f2a8bd7b54a0b0b74d439c.tar.gz ungrateful-1cf89852f951b59b89f2a8bd7b54a0b0b74d439c.zip |
memory manipulation, strings, allocators list and logger.
Diffstat (limited to 'tests/allocs.c')
-rw-r--r-- | tests/allocs.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/allocs.c b/tests/allocs.c new file mode 100644 index 0000000..608d9f4 --- /dev/null +++ b/tests/allocs.c @@ -0,0 +1,39 @@ +#include <ungrateful.h> + +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); + } +} |