1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:47:35 +00:00

Kernel: Convert RangeAllocator to using a RedBlackTree internally

This data structure is a much better fit for what is essentially a
sorted list of non-overlapping ranges.

Not using Vector means we no longer have to worry about Vector buffers
getting huge. Only nice & small allocations from now on.
This commit is contained in:
Andreas Kling 2021-07-15 01:40:46 +02:00
parent 980f409003
commit 15ad4a8fd6
2 changed files with 42 additions and 42 deletions

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/RedBlackTree.h>
#include <AK/Traits.h>
#include <AK/Vector.h>
#include <Kernel/SpinLock.h>
#include <Kernel/VM/Range.h>
@ -31,9 +31,9 @@ public:
bool contains(Range const& range) const { return m_total_range.contains(range); }
private:
void carve_at_index(int, Range const&);
void carve_at_iterator(auto&, Range const&);
Vector<Range> m_available_ranges;
RedBlackTree<FlatPtr, Range> m_available_ranges;
Range m_total_range;
mutable SpinLock<u8> m_lock;
};