From e5925df93411429340d2887594004aaa690d2ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Mon, 28 Oct 2024 13:32:09 +0000 Subject: Adjust constant and make all possible variables const --- arch/x86_64/src/memory/allocator/area_frame_allocator.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'arch/x86_64/src/memory/allocator') diff --git a/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp b/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp index e03c66a..6ec3e95 100644 --- a/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp +++ b/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp @@ -28,7 +28,7 @@ namespace teachos::arch::memory::allocator return physical_frame::containing_address(address) >= next_free_frame; }); - auto lowest_area_with_free_frames = + auto const lowest_area_with_free_frames = std::ranges::min_element(next_area_with_free_frames, [](multiboot::memory_area a, multiboot::memory_area b) { return a.base_address < b.base_address; }); @@ -37,7 +37,7 @@ namespace teachos::arch::memory::allocator { current_area = *lowest_area_with_free_frames; // Update the `next_free_frame` according to the new memory area - auto start_frame = physical_frame::containing_address(current_area.value().base_address); + auto const start_frame = physical_frame::containing_address(current_area.value().base_address); if (next_free_frame < start_frame) { next_free_frame = start_frame; @@ -47,16 +47,14 @@ namespace teachos::arch::memory::allocator auto area_frame_allocator::allocate_frame() -> std::optional { - /* - * Only try to allocate memory if current_area is not null, because - * the current_area is null if there is no more available memory. - */ + // Only try to allocate memory if current_area is not null, because + // the current_area is null if there is no more available memory. if (!current_area.has_value()) { return std::nullopt; } - auto address = current_area.value().base_address + current_area.value().area_length - 1; + auto const address = current_area.value().base_address + current_area.value().area_length - 1; physical_frame current_area_last_frame = physical_frame::containing_address(address); if (next_free_frame > current_area_last_frame) -- cgit v1.2.3