mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:37:34 +00:00
Kernel: Make VirtualRangeAllocator setup functions propagate errors
If an internal allocation failure occurs while setting up a new VRA, we'll now propagate the error to our caller instead of panicking.
This commit is contained in:
parent
0f22ba5bf2
commit
578a576a98
3 changed files with 11 additions and 9 deletions
|
@ -17,20 +17,22 @@ VirtualRangeAllocator::VirtualRangeAllocator()
|
|||
{
|
||||
}
|
||||
|
||||
void VirtualRangeAllocator::initialize_with_range(VirtualAddress base, size_t size)
|
||||
ErrorOr<void> VirtualRangeAllocator::initialize_with_range(VirtualAddress base, size_t size)
|
||||
{
|
||||
m_total_range = { base, size };
|
||||
m_available_ranges.insert(base.get(), VirtualRange { base, size });
|
||||
TRY(m_available_ranges.try_insert(base.get(), VirtualRange { base, size }));
|
||||
return {};
|
||||
}
|
||||
|
||||
void VirtualRangeAllocator::initialize_from_parent(VirtualRangeAllocator const& parent_allocator)
|
||||
ErrorOr<void> VirtualRangeAllocator::initialize_from_parent(VirtualRangeAllocator const& parent_allocator)
|
||||
{
|
||||
SpinlockLocker lock(parent_allocator.m_lock);
|
||||
m_total_range = parent_allocator.m_total_range;
|
||||
m_available_ranges.clear();
|
||||
for (auto it = parent_allocator.m_available_ranges.begin(); !it.is_end(); ++it) {
|
||||
m_available_ranges.insert(it.key(), *it);
|
||||
TRY(m_available_ranges.try_insert(it.key(), VirtualRange(*it)));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void VirtualRangeAllocator::dump() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue