From 359a04ba9623d67bb1cfd05edb8caef0ca66af3a Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 9 Oct 2024 22:29:52 -0400 Subject: [PATCH] bootloader: Cleanup handling of LargeAllocations. * Remove unused SetTo; clear Address/Size to 0 on init. * Free all LargeAllocations in heap_release. (This method isn't actually called by default before kernel entry, though, so it probably doesn't matter much.) Change-Id: If038274adcd65adae527235d16860af659ef37b6 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8439 Reviewed-by: waddlesplash Haiku-Format: Haiku-format Bot --- src/system/boot/loader/heap.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/system/boot/loader/heap.cpp b/src/system/boot/loader/heap.cpp index 4b201a8767..c9e7a701e8 100644 --- a/src/system/boot/loader/heap.cpp +++ b/src/system/boot/loader/heap.cpp @@ -174,12 +174,8 @@ typedef IteratableSplayTree FreeChunkTree; struct LargeAllocation { LargeAllocation() { - } - - void SetTo(void* address, size_t size) - { - fAddress = address; - fSize = size; + fAddress = NULL; + fSize = 0; } status_t Allocate(size_t size) @@ -387,6 +383,13 @@ FreeChunk::SetToAllocated(void* allocated) void heap_release(stage2_args* args) { + LargeAllocation* allocation = sLargeAllocations.Clear(true); + while (allocation != NULL) { + LargeAllocation* next = allocation->HashNext(); + allocation->Free(); + allocation = next; + } + platform_release_heap(args, sHeapBase); }