Make allocate take a template type

So we use the right alignment
This commit is contained in:
2025-08-15 13:31:45 -04:00
parent 52f0eeee1f
commit 8e33b477eb
5 changed files with 117 additions and 63 deletions

View File

@@ -67,7 +67,7 @@ void ArenaAllocator::reset() {
void *ArenaAllocator::realloc(void *ptr, size_t old_size, size_t new_size,
size_t alignment) {
if (ptr == nullptr) {
return allocate(new_size, alignment);
return allocate_raw(new_size, alignment);
}
if (new_size == old_size) {
@@ -119,7 +119,7 @@ void *ArenaAllocator::realloc(void *ptr, size_t old_size, size_t new_size,
}
// Growing but can't extend in place - need to allocate new space and copy
void *new_ptr = allocate(new_size, alignment);
void *new_ptr = allocate_raw(new_size, alignment);
if (new_ptr && ptr) {
// Copy all the old data since we're growing
std::memcpy(new_ptr, ptr, old_size);