aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/memory/allocator
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-04 13:29:03 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-04 13:29:03 +0000
commit30466aeb3da181c21bd451f32c1ff97e53a55dbc (patch)
tree6187ccc6f260edaa2bde5207997ea7584837676e /arch/x86_64/src/memory/allocator
parent162bea11c7a4f1854cde53920b4c14b4eadf539d (diff)
downloadkernel-30466aeb3da181c21bd451f32c1ff97e53a55dbc.tar.xz
kernel-30466aeb3da181c21bd451f32c1ff97e53a55dbc.zip
Use more concepts and seperate iterator implementations
Diffstat (limited to 'arch/x86_64/src/memory/allocator')
-rw-r--r--arch/x86_64/src/memory/allocator/area_frame_allocator.cpp6
-rw-r--r--arch/x86_64/src/memory/allocator/physical_frame.cpp27
2 files changed, 3 insertions, 30 deletions
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 42aff68..3bc9676 100644
--- a/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp
+++ b/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp
@@ -24,16 +24,16 @@ namespace teachos::arch::memory::allocator
{
current_area = std::nullopt;
auto next_area_with_free_frames = memory_areas | std::views::filter([this](auto const & area) {
- auto address = area->base_address + area->area_length - 1;
+ auto address = area.base_address + area.area_length - 1;
return physical_frame::containing_address(address) >= next_free_frame;
});
auto const lowest_area_with_free_frames = std::ranges::min_element(
- next_area_with_free_frames, [](auto const & a, auto const & b) { return a->base_address < b->base_address; });
+ next_area_with_free_frames, [](auto const & a, auto const & b) { return a.base_address < b.base_address; });
if (lowest_area_with_free_frames != next_area_with_free_frames.end())
{
- current_area = **lowest_area_with_free_frames;
+ current_area = *lowest_area_with_free_frames;
// Update the `next_free_frame` according to the new memory area
auto const start_frame = physical_frame::containing_address(current_area.value().base_address);
if (next_free_frame < start_frame)
diff --git a/arch/x86_64/src/memory/allocator/physical_frame.cpp b/arch/x86_64/src/memory/allocator/physical_frame.cpp
index 63d84ec..ec387a1 100644
--- a/arch/x86_64/src/memory/allocator/physical_frame.cpp
+++ b/arch/x86_64/src/memory/allocator/physical_frame.cpp
@@ -21,31 +21,4 @@ namespace teachos::arch::memory::allocator
++frame_number;
return *this;
}
-
- auto physical_frame::operator+=(std::size_t operand) -> physical_frame &
- {
- frame_number += operand;
- return *this;
- }
-
- auto physical_frame::operator-=(std::size_t operand) -> physical_frame &
- {
- frame_number -= operand;
- return *this;
- }
-
- auto physical_frame::operator+(std::size_t operand) const -> physical_frame
- {
- return physical_frame{frame_number + operand};
- }
-
- auto physical_frame::operator-(std::size_t operand) const -> physical_frame
- {
- return physical_frame{frame_number - operand};
- }
-
- auto physical_frame::operator-(const physical_frame & other) const -> std::size_t
- {
- return frame_number - other.frame_number;
- }
} // namespace teachos::arch::memory::allocator