|
@@ -404,7 +404,7 @@ void *alloc(Arena *arena, uintptr_t size, uintptr_t align) {
|
404
|
404
|
return alloc(arena, size, align);
|
405
|
405
|
}
|
406
|
406
|
remove_node((TreeAlloc**) &arena->root_freespace, region);
|
407
|
|
- void *true_end = align_after(align_after(region + sizeof(TreeAlloc), actual_align) + size, alignof(WatermarkAlloc));
|
|
407
|
+ void *true_end = align_after(align_after(((void*) region) + sizeof(TreeAlloc), actual_align) + size, alignof(WatermarkAlloc));
|
408
|
408
|
// The size of the new allocation (adjusted for region header and alignment
|
409
|
409
|
uintptr_t new_size = true_end - (void*) region;
|
410
|
410
|
// 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) {
|
412
|
412
|
region->right = NULL;
|
413
|
413
|
region->left = NULL;
|
414
|
414
|
region->type = RT_TREE_NODE;
|
|
415
|
+#ifdef DEBUG
|
|
416
|
+ printf("sizeof(TreeAlloc): %lu\n", (uintptr_t) sizeof(TreeAlloc));
|
|
417
|
+ printf("start: %p, end: %p, adjusted end: %p\n", region, ((void*) region) + size, true_end);
|
|
418
|
+ printf("size: %lu -> %lu\n", size, new_size);
|
|
419
|
+#endif
|
415
|
420
|
if (arena->root_treealloc == NULL) {
|
416
|
421
|
insert_singleton((TreeAlloc**) &arena->root_treealloc, region);
|
417
|
422
|
} else {
|