Rename mem allocator

This commit is contained in:
2026-06-26 16:24:03 +01:00
parent 99d6404ec4
commit f4bffec947
31 changed files with 167 additions and 167 deletions
+10 -10
View File
@@ -7,15 +7,15 @@
#define TEMP_BUF_SIZE (40 + sizeof(i32) * 8)
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {0};
wp_intern Allocator temp_allocator = {0};
wp_intern WpAllocator temp_allocator = {0};
WpTestFuncResult test_arena_allocator(void) {
Allocator allocator = wapp_mem_arena_allocator_init(4096);
WpAllocator allocator = wapp_mem_arena_allocator_init(4096);
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);
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
result = result && (ptr != NULL);
wapp_mem_arena_allocator_destroy(&allocator);
@@ -26,12 +26,12 @@ WpTestFuncResult test_arena_allocator(void) {
WpTestFuncResult test_arena_allocator_with_buffer(void) {
u8 buffer[KiB(4)] = {0};
Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
WpAllocator 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);
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
result = result && (ptr != NULL);
wapp_mem_arena_allocator_destroy(&allocator);
@@ -42,13 +42,13 @@ WpTestFuncResult test_arena_allocator_with_buffer(void) {
WpTestFuncResult test_arena_allocator_temp_begin(void) {
temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
b8 result = num1 != NULL;
wapp_mem_arena_allocator_temp_begin(&temp_allocator);
i32 *num2 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
result = result && num2 != NULL;
i32 *num3 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num3 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
result = result && num3 == NULL;
return wpTesterResult(result);
@@ -56,9 +56,9 @@ WpTestFuncResult test_arena_allocator_temp_begin(void) {
WpTestFuncResult test_arena_allocator_temp_end(void) {
wapp_mem_arena_allocator_temp_end(&temp_allocator);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
b8 result = num1 != NULL;
i32 *num2 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
result = result && num2 == NULL;
wapp_mem_arena_allocator_destroy(&temp_allocator);
+10 -10
View File
@@ -7,15 +7,15 @@
#define TEMP_BUF_SIZE (40 + sizeof(i32) * 8)
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {};
wp_intern Allocator temp_allocator = {};
wp_intern WpAllocator temp_allocator = {};
WpTestFuncResult test_arena_allocator(void) {
Allocator allocator = wapp_mem_arena_allocator_init(4096);
WpAllocator allocator = wapp_mem_arena_allocator_init(4096);
b8 result = allocator.obj != nullptr && allocator.alloc != nullptr &&
allocator.alloc_aligned != nullptr &&
allocator.realloc != nullptr && allocator.realloc_aligned != nullptr &&
allocator.free == nullptr;
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
result = result && (ptr != nullptr);
wapp_mem_arena_allocator_destroy(&allocator);
@@ -26,12 +26,12 @@ WpTestFuncResult test_arena_allocator(void) {
WpTestFuncResult test_arena_allocator_with_buffer(void) {
u8 buffer[KiB(4)] = {0};
Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
WpAllocator 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);
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
result = result && (ptr != NULL);
wapp_mem_arena_allocator_destroy(&allocator);
@@ -42,13 +42,13 @@ WpTestFuncResult test_arena_allocator_with_buffer(void) {
WpTestFuncResult test_arena_allocator_temp_begin(void) {
temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
b8 result = num1 != NULL;
wapp_mem_arena_allocator_temp_begin(&temp_allocator);
i32 *num2 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
result = result && num2 != NULL;
i32 *num3 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num3 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
result = result && num3 == NULL;
return wpTesterResult(result);
@@ -56,9 +56,9 @@ WpTestFuncResult test_arena_allocator_temp_begin(void) {
WpTestFuncResult test_arena_allocator_temp_end(void) {
wapp_mem_arena_allocator_temp_end(&temp_allocator);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
b8 result = num1 != NULL;
i32 *num2 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
result = result && num2 == NULL;
wapp_mem_arena_allocator_destroy(&temp_allocator);
+4 -4
View File
@@ -148,7 +148,7 @@ WpTestFuncResult test_i32_array_copy_capped(void) {
WpTestFuncResult test_i32_array_alloc_capacity(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
u64 capacity = 32;
I32Array array = wapp_array_alloc_capacity(i32, &allocator, capacity, ARRAY_INIT_NONE);
@@ -162,7 +162,7 @@ WpTestFuncResult test_i32_array_alloc_capacity(void) {
WpTestFuncResult test_i32_array_append_alloc(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, 1, 2);
@@ -189,7 +189,7 @@ WpTestFuncResult test_i32_array_append_alloc(void) {
WpTestFuncResult test_i32_array_extend_alloc(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, 1, 2);
I32Array array3 = wapp_array(i32, 1, 2, 3, 4);
@@ -208,7 +208,7 @@ WpTestFuncResult test_i32_array_extend_alloc(void) {
WpTestFuncResult test_i32_array_copy_alloc(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array src = wapp_array(i32, 1, 2, 3, 4, 5);
I32Array dst1 = wapp_array(i32, 1, 2, 3, 4, 5, 6);
I32Array dst2 = wapp_array(i32, 1, 2);
+4 -4
View File
@@ -150,7 +150,7 @@ WpTestFuncResult test_i32_array_copy_capped(void) {
WpTestFuncResult test_i32_array_alloc_capacity(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
u64 capacity = 32;
I32Array array = wapp_array_alloc_capacity(i32, &allocator, capacity, ARRAY_INIT_NONE);
@@ -164,7 +164,7 @@ WpTestFuncResult test_i32_array_alloc_capacity(void) {
WpTestFuncResult test_i32_array_append_alloc(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, 1, 2);
@@ -192,7 +192,7 @@ WpTestFuncResult test_i32_array_append_alloc(void) {
WpTestFuncResult test_i32_array_extend_alloc(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, 1, 2);
I32Array array3 = wapp_array(i32, 1, 2, 3, 4);
@@ -211,7 +211,7 @@ WpTestFuncResult test_i32_array_extend_alloc(void) {
WpTestFuncResult test_i32_array_copy_alloc(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array src = wapp_array(i32, 1, 2, 3, 4, 5);
I32Array dst1 = wapp_array(i32, 1, 2, 3, 4, 5, 6);
I32Array dst2 = wapp_array(i32, 1, 2);
+4 -4
View File
@@ -81,8 +81,8 @@ WpTestFuncResult test_cpath_join_path(void) {
}
WpTestFuncResult test_cpath_dirname(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) {
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wpMemAllocatorInvalid(&arena)) {
return wpTesterResult(false);
}
@@ -129,8 +129,8 @@ WpTestFuncResult test_cpath_dirname(void) {
}
WpTestFuncResult test_cpath_dirup(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) {
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wpMemAllocatorInvalid(&arena)) {
return wpTesterResult(false);
}
+4 -4
View File
@@ -99,8 +99,8 @@ WpTestFuncResult test_cpath_join_path(void) {
}
WpTestFuncResult test_cpath_dirname(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) {
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wpMemAllocatorInvalid(&arena)) {
return wpTesterResult(false);
}
@@ -149,8 +149,8 @@ WpTestFuncResult test_cpath_dirname(void) {
}
WpTestFuncResult test_cpath_dirup(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) {
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wpMemAllocatorInvalid(&arena)) {
return wpTesterResult(false);
}
+1 -1
View File
@@ -3,7 +3,7 @@
#include "test_file.h"
#define DST_CAPACITY 5
wp_intern Allocator arena = {0};
wp_intern WpAllocator arena = {0};
wp_intern WpStr8RO test_filename = wpStr8LitRoInitialiserList("wapptest.bin");
wp_intern WpStr8RO new_filename = wpStr8LitRoInitialiserList("wapptest2.bin");
wp_intern WFile *test_fp = NULL;
+1 -1
View File
@@ -3,7 +3,7 @@
#include "test_file.h"
#define DST_CAPACITY 5
wp_intern Allocator arena = {};
wp_intern WpAllocator arena = {};
wp_intern WpStr8RO test_filename = wpStr8LitRoInitialiserList("wapptest.bin");
wp_intern WpStr8RO new_filename = wpStr8LitRoInitialiserList("wapptest2.bin");
wp_intern WFile *test_fp = NULL;
+1 -1
View File
@@ -23,7 +23,7 @@ WpTestFuncResult test_queue_push(void) {
}
WpTestFuncResult test_queue_push_alloc(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(64));
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(64));
I32Queue queue = wapp_queue(i32, CAPACITY);
for (u64 i = 0; i < CAPACITY; ++i) {
+1 -1
View File
@@ -21,7 +21,7 @@ WpTestFuncResult test_queue_push(void) {
}
WpTestFuncResult test_queue_push_alloc(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(64));
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(64));
I32Queue queue = wapp_queue(i32, CAPACITY);
for (u64 i = 0; i < CAPACITY; ++i) {
+14 -14
View File
@@ -77,8 +77,8 @@ WpTestFuncResult test_str8_buf(void) {
WpTestFuncResult test_str8_alloc_buf(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -105,8 +105,8 @@ TEST_ALLOC_BUF_CLEANUP:
WpTestFuncResult test_str8_alloc_cstr(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -126,8 +126,8 @@ WpTestFuncResult test_str8_alloc_cstr(void) {
WpTestFuncResult test_str8_alloc_str8(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -146,8 +146,8 @@ WpTestFuncResult test_str8_alloc_str8(void) {
WpTestFuncResult test_str8_alloc_substr(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -289,7 +289,7 @@ WpTestFuncResult test_str8_slice(void) {
WpTestFuncResult test_str8_alloc_concat(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("Hello world");
WpStr8 suffix1 = wpStr8Lit(" from me.");
@@ -410,7 +410,7 @@ WpTestFuncResult test_str8_rfind(void) {
WpTestFuncResult test_str8_split(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim1 = wpStr8Lit(" ");
@@ -467,7 +467,7 @@ WpTestFuncResult test_str8_split(void) {
WpTestFuncResult test_str8_split_with_max(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim = wpStr8Lit(" ");
@@ -502,7 +502,7 @@ WpTestFuncResult test_str8_split_with_max(void) {
WpTestFuncResult test_str8_rsplit(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim1 = wpStr8Lit(" ");
@@ -559,7 +559,7 @@ WpTestFuncResult test_str8_rsplit(void) {
WpTestFuncResult test_str8_rsplit_with_max(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim = wpStr8Lit(" ");
@@ -594,7 +594,7 @@ WpTestFuncResult test_str8_rsplit_with_max(void) {
WpTestFuncResult test_str8_join(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim1 = wpStr8Lit(" ");
+14 -14
View File
@@ -77,8 +77,8 @@ WpTestFuncResult test_str8_buf(void) {
WpTestFuncResult test_str8_alloc_buf(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -105,8 +105,8 @@ WpTestFuncResult test_str8_alloc_buf(void) {
WpTestFuncResult test_str8_alloc_cstr(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -126,8 +126,8 @@ WpTestFuncResult test_str8_alloc_cstr(void) {
WpTestFuncResult test_str8_alloc_str8(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -146,8 +146,8 @@ WpTestFuncResult test_str8_alloc_str8(void) {
WpTestFuncResult test_str8_alloc_substr(void) {
b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) {
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wpMemAllocatorInvalid(&allocator)) {
return wpTesterResult(false);
}
@@ -289,7 +289,7 @@ WpTestFuncResult test_str8_slice(void) {
WpTestFuncResult test_str8_alloc_concat(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("Hello world");
WpStr8 suffix1 = wpStr8Lit(" from me.");
@@ -410,7 +410,7 @@ WpTestFuncResult test_str8_rfind(void) {
WpTestFuncResult test_str8_split(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim1 = wpStr8Lit(" ");
@@ -467,7 +467,7 @@ WpTestFuncResult test_str8_split(void) {
WpTestFuncResult test_str8_split_with_max(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim = wpStr8Lit(" ");
@@ -502,7 +502,7 @@ WpTestFuncResult test_str8_split_with_max(void) {
WpTestFuncResult test_str8_rsplit(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim1 = wpStr8Lit(" ");
@@ -559,7 +559,7 @@ WpTestFuncResult test_str8_rsplit(void) {
WpTestFuncResult test_str8_rsplit_with_max(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim = wpStr8Lit(" ");
@@ -594,7 +594,7 @@ WpTestFuncResult test_str8_rsplit_with_max(void) {
WpTestFuncResult test_str8_join(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
WpStr8 str = wpStr8Lit("hello world from me");
WpStr8 delim1 = wpStr8Lit(" ");