aboutsummaryrefslogtreecommitdiff
path: root/src/std/arena_allocator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/std/arena_allocator.c')
-rw-r--r--src/std/arena_allocator.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/std/arena_allocator.c b/src/std/arena_allocator.c
index 14787f1..73111dd 100644
--- a/src/std/arena_allocator.c
+++ b/src/std/arena_allocator.c
@@ -67,8 +67,7 @@ static CHECK_RESULT int arena_allocator_ensure_capacity_for(ArenaAllocator *self
}
static void* align_ptr_ceil(void *ptr, uintptr_t alignment) {
- uintptr_t ptrval;
- ptrval = (uintptr_t)ptr;
+ const uintptr_t ptrval = (uintptr_t)ptr;
return (void*)((ptrval + alignment + 1) & ~(alignment - 1));
}
@@ -76,7 +75,7 @@ static usize align_ptr_ceil_offset(void *ptr, uintptr_t alignment) {
return (uintptr_t)align_ptr_ceil(ptr, alignment) - (uintptr_t)ptr;
}
-#define SCOPED_ALLOC_ALIGNMENT 8
+#define ALLOC_ALIGNMENT 8
int arena_allocator_alloc(ArenaAllocator *self, usize size, void **mem) {
ArenaAllocatorNode *current;
@@ -89,14 +88,14 @@ int arena_allocator_alloc(ArenaAllocator *self, usize size, void **mem) {
return -1;
}
- alloc_size = size + align_ptr_ceil_offset(self->current->data + self->current->size, SCOPED_ALLOC_ALIGNMENT);
+ alloc_size = size + align_ptr_ceil_offset(self->current->data + self->current->size, ALLOC_ALIGNMENT);
return_if_error(arena_allocator_ensure_capacity_for(self, alloc_size));
/* Reallocated (new node created) */
if(self->current != current) {
*mem = self->current->data;
self->current->size += size;
} else {
- *mem = align_ptr_ceil(self->current->data + self->current->size, SCOPED_ALLOC_ALIGNMENT);
+ *mem = align_ptr_ceil(self->current->data + self->current->size, ALLOC_ALIGNMENT);
self->current->size += alloc_size;
}
return 0;