mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
AK+Everywhere: Make FixedArray OOM-safe
FixedArray now doesn't expose any infallible constructors anymore. Rather, it exposes fallible methods. Therefore, it can be used for OOM-safe code. This commit also converts the rest of the system to use the new API. However, as an example, VMObject can't take advantage of this yet, as we would have to endow VMObject with a fallible static construction method, which would require a very fundamental change to VMObject's whole inheritance hierarchy.
This commit is contained in:
parent
a7b70c62d7
commit
3c05261611
5 changed files with 62 additions and 34 deletions
|
@ -18,13 +18,13 @@ SpinlockProtected<VMObject::AllInstancesList>& VMObject::all_instances()
|
|||
}
|
||||
|
||||
VMObject::VMObject(VMObject const& other)
|
||||
: m_physical_pages(other.m_physical_pages)
|
||||
: m_physical_pages(other.m_physical_pages.must_clone_but_fixme_should_propagate_errors())
|
||||
{
|
||||
all_instances().with([&](auto& list) { list.append(*this); });
|
||||
}
|
||||
|
||||
VMObject::VMObject(size_t size)
|
||||
: m_physical_pages(ceil_div(size, static_cast<size_t>(PAGE_SIZE)))
|
||||
: m_physical_pages(FixedArray<RefPtr<PhysicalPage>>::must_create_but_fixme_should_propagate_errors(ceil_div(size, static_cast<size_t>(PAGE_SIZE))))
|
||||
{
|
||||
all_instances().with([&](auto& list) { list.append(*this); });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue