diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-27 21:01:45 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-27 21:14:42 +0100 |
commit | e67402c7027f13fcc03d61f88725470e4c66e820 (patch) | |
tree | 673d40ced3c4dec8da64200ee21c4c8398d6fcb6 /Kernel/VM/RangeAllocator.cpp | |
parent | 67bc5e0bbdcf313b20b32069a5e9b9806f8bd790 (diff) | |
download | serenity-e67402c7027f13fcc03d61f88725470e4c66e820.zip |
Kernel: Remove Range "valid" state and use Optional<Range> instead
It's easier to understand VM ranges if they are always valid. We can
simply use an empty Optional<Range> to encode absence when needed.
Diffstat (limited to 'Kernel/VM/RangeAllocator.cpp')
-rw-r--r-- | Kernel/VM/RangeAllocator.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Kernel/VM/RangeAllocator.cpp b/Kernel/VM/RangeAllocator.cpp index ec5174bf04..c6292cc715 100644 --- a/Kernel/VM/RangeAllocator.cpp +++ b/Kernel/VM/RangeAllocator.cpp @@ -36,6 +36,7 @@ namespace Kernel { RangeAllocator::RangeAllocator() + : m_total_range({}, 0) { } @@ -105,7 +106,7 @@ void RangeAllocator::carve_at_index(int index, const Range& range) m_available_ranges.insert(index + 1, move(remaining_parts[1])); } -Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment) +Optional<Range> RangeAllocator::allocate_anywhere(size_t size, size_t alignment) { if (!size) return {}; @@ -148,7 +149,7 @@ Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment) return {}; } -Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size) +Optional<Range> RangeAllocator::allocate_specific(VirtualAddress base, size_t size) { if (!size) return {}; @@ -178,7 +179,7 @@ Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size) return {}; } -void RangeAllocator::deallocate(Range range) +void RangeAllocator::deallocate(const Range& range) { ScopedSpinLock lock(m_lock); ASSERT(m_total_range.contains(range)); |