|
|
@ -404,7 +404,7 @@ void *alloc(Arena *arena, uintptr_t size, uintptr_t align) { |
|
|
|
return alloc(arena, size, align); |
|
|
|
} |
|
|
|
remove_node((TreeAlloc**) &arena->root_freespace, region); |
|
|
|
void *true_end = align_after(align_after(region + sizeof(TreeAlloc), actual_align) + size, alignof(WatermarkAlloc)); |
|
|
|
void *true_end = align_after(align_after(((void*) region) + sizeof(TreeAlloc), actual_align) + size, alignof(WatermarkAlloc)); |
|
|
|
// The size of the new allocation (adjusted for region header and alignment |
|
|
|
uintptr_t new_size = true_end - (void*) region; |
|
|
|
// The size of the free space region following the new allocation |
|
|
@ -412,6 +412,11 @@ void *alloc(Arena *arena, uintptr_t size, uintptr_t align) { |
|
|
|
region->right = NULL; |
|
|
|
region->left = NULL; |
|
|
|
region->type = RT_TREE_NODE; |
|
|
|
#ifdef DEBUG |
|
|
|
printf("sizeof(TreeAlloc): %lu\n", (uintptr_t) sizeof(TreeAlloc)); |
|
|
|
printf("start: %p, end: %p, adjusted end: %p\n", region, ((void*) region) + size, true_end); |
|
|
|
printf("size: %lu -> %lu\n", size, new_size); |
|
|
|
#endif |
|
|
|
if (arena->root_treealloc == NULL) { |
|
|
|
insert_singleton((TreeAlloc**) &arena->root_treealloc, region); |
|
|
|
} else { |
|
|
|