mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:28:11 +00:00
Kernel: Remove old region from process' regions vector before splitting
This does not affect functionality right now, but it means that the regions vector will now never have any overlapping regions, which will allow the use of balance binary search trees instead of a vector in the future. (since they require keys to be exclusive)
This commit is contained in:
parent
f8a3da46fd
commit
497c759ab7
3 changed files with 36 additions and 20 deletions
|
@ -118,18 +118,21 @@ KResultOr<Region*> Space::allocate_region_with_vmobject(const Range& range, Nonn
|
|||
|
||||
bool Space::deallocate_region(Region& region)
|
||||
{
|
||||
OwnPtr<Region> region_protector;
|
||||
return take_region(region);
|
||||
}
|
||||
|
||||
OwnPtr<Region> Space::take_region(Region& region)
|
||||
{
|
||||
ScopedSpinLock lock(m_lock);
|
||||
|
||||
if (m_region_lookup_cache.region.unsafe_ptr() == ®ion)
|
||||
m_region_lookup_cache.region = nullptr;
|
||||
for (size_t i = 0; i < m_regions.size(); ++i) {
|
||||
if (&m_regions[i] == ®ion) {
|
||||
region_protector = m_regions.unstable_take(i);
|
||||
return true;
|
||||
return m_regions.unstable_take(i);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
Region* Space::find_region_from_range(const Range& range)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue