BlockArena, a bit of allocator rework

This commit is contained in:
Krzosa Karol
2025-11-30 19:54:46 +01:00
parent c19c60fe22
commit c2f4686bc4
15 changed files with 337 additions and 224 deletions

View File

@@ -214,7 +214,7 @@ void Reserve(Array<T> *arr, int64_t size) {
T *new_data = AllocArray(arr->allocator, T, size);
Assert(new_data);
memcpy(new_data, arr->data, arr->len * sizeof(T));
Dealloc(arr->allocator, &arr->data);
Dealloc(arr->allocator, arr->data);
arr->data = new_data;
arr->cap = size;
@@ -393,7 +393,10 @@ T Get(Array<T> &arr, int64_t i, T default_value = {}) {
template <class T>
void Dealloc(Array<T> *arr) {
if (arr->data) Dealloc(arr->allocator, &arr->data);
if (arr->data) {
Dealloc(arr->allocator, arr->data);
arr->data = NULL;
}
arr->len = arr->cap = 0;
}