This commit is contained in:
2025-12-14 12:40:32 +01:00
parent c9959cdb5b
commit 308cb6e83d
10 changed files with 48 additions and 219 deletions
+2 -4
View File
@@ -1,13 +1,11 @@
#include "cig.h"
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;
bytes = (bytes + MAX_ALIGN - 1) / MAX_ALIGN * MAX_ALIGN;
size_t new_size = this->size + bytes;
if (new_size > this->capacity) {
return NULL;
}
this->size += offset;
void *ptr = &this->data[this->size];
this->size = new_size;
return ptr;