diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-03 11:03:34 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-03 11:03:34 +0000 |
| commit | 9292814545ab5df5aa69d4f75a6d9230f3e03f5b (patch) | |
| tree | 4d3cd879c21e3f14867fce0cb78c7aa73fc812c6 /arch/x86_64/src/memory/allocator | |
| parent | d4b1b8a85212f07df47217fe13d86956c7eb064f (diff) | |
| download | kernel-9292814545ab5df5aa69d4f75a6d9230f3e03f5b.tar.xz kernel-9292814545ab5df5aa69d4f75a6d9230f3e03f5b.zip | |
Move possible implementation into cpp
Diffstat (limited to 'arch/x86_64/src/memory/allocator')
| -rw-r--r-- | arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp b/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp index b9fd2c8..d37864e 100644 --- a/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp +++ b/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp @@ -4,6 +4,22 @@ namespace teachos::arch::memory::allocator { + tiny_frame_allocator::tiny_frame_allocator(area_frame_allocator & allocator) + : frames{} + { + // Has to be done this way, because constructing the constructor with the data from allocator.allocate_frames(), + // does not work because it would set the value correctly but because we pass it as an std::optional it would not + // set the engaged flag. Meaning the has_value() method would still return false. + for (auto & frame : frames) + { + auto allocated = allocator.allocate_frame(); + if (allocated.has_value()) + { + frame.emplace(allocated.value()); + } + } + } + auto tiny_frame_allocator::allocate_frame() -> std::optional<physical_frame> { for (auto & frame_option : frames) |
