arena allocators are fully implemented

This commit is contained in:
2025-12-06 14:19:53 +01:00
parent b912759050
commit d6ad1c7602
5 changed files with 92 additions and 10 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
#include "cig.h"
void *buffer_allocator_alloc(buffer_allocator_t *this, size_t bytes) {
static void *buffer_allocator_alloc(buffer_allocator_t *this, size_t 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;
@@ -13,7 +13,7 @@ void *buffer_allocator_alloc(buffer_allocator_t *this, size_t bytes) {
return ptr;
}
void *buffer_allocator_resize(buffer_allocator_t *this, void *old_ptr, size_t bytes) {
static void *buffer_allocator_resize(buffer_allocator_t *this, void *old_ptr, size_t bytes) {
void *new_ptr = buffer_allocator_alloc(this, bytes);
if (new_ptr == NULL) {
return NULL;
@@ -26,7 +26,7 @@ void *buffer_allocator_resize(buffer_allocator_t *this, void *old_ptr, size_t by
return new_ptr;
}
void buffer_allocator_reset(buffer_allocator_t *this) {
static void buffer_allocator_reset(buffer_allocator_t *this) {
this->size = 0;
}