WIP continue the work on arena allcoator implementation

This commit is contained in:
2025-11-17 20:23:42 +01:00
parent 92ca008516
commit 78cc6c5cae
5 changed files with 55 additions and 18 deletions
+4 -3
View File
@@ -1,12 +1,13 @@
#include "cig.h"
void *buffer_allocator_alloc(buffer_allocator_t *this, size_t bytes) {
// TODO: use max-align
// also make the default function crash if outOf memory?
size_t new_size = this->size + bytes;
size_t address_of_new_data = (size_t) &this->data[this->size];
size_t offset = address_of_new_data % MAX_ALIGN;
size_t new_size = this->size + offset + bytes;
if (new_size > this->capacity) {
return NULL;
}
this->size += offset;
void *ptr = &this->data[this->size];
this->size = new_size;
return ptr;