mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 13:43:45 +03:00
Kernel: Make PrivateInodeVMObject construction OOM-aware
This commit moves the allocation of the resources required for PrivateInodeVMObject from its constructors to its factory functions. We're making this change to expose the fallibility of the allocation.
This commit is contained in:
parent
ad480ff18b
commit
9a1dfe70fe
Notes:
sideshowbarker
2024-07-17 20:50:09 +09:00
Author: https://github.com/creator1creeper1 Commit: https://github.com/SerenityOS/serenity/commit/9a1dfe70fe5 Pull-request: https://github.com/SerenityOS/serenity/pull/11843 Reviewed-by: https://github.com/IdanHo ✅ Reviewed-by: https://github.com/bgianfo
@ -11,21 +11,23 @@ namespace Kernel::Memory {
|
||||
|
||||
ErrorOr<NonnullRefPtr<PrivateInodeVMObject>> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, inode.size()));
|
||||
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(inode.size()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, move(new_physical_pages)));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<VMObject>> PrivateInodeVMObject::try_clone()
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) PrivateInodeVMObject(*this));
|
||||
auto new_physical_pages = TRY(this->try_clone_physical_pages());
|
||||
return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) PrivateInodeVMObject(*this, move(new_physical_pages)));
|
||||
}
|
||||
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, size_t size)
|
||||
: InodeVMObject(inode, VMObject::must_create_physical_pages_but_fixme_should_propagate_errors(size))
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
: InodeVMObject(inode, move(new_physical_pages))
|
||||
{
|
||||
}
|
||||
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other)
|
||||
: InodeVMObject(other, other.must_clone_physical_pages_but_fixme_should_propagate_errors())
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
: InodeVMObject(other, move(new_physical_pages))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ public:
|
||||
private:
|
||||
virtual bool is_private_inode() const override { return true; }
|
||||
|
||||
explicit PrivateInodeVMObject(Inode&, size_t);
|
||||
explicit PrivateInodeVMObject(PrivateInodeVMObject const&);
|
||||
explicit PrivateInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
explicit PrivateInodeVMObject(PrivateInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
|
||||
virtual StringView class_name() const override { return "PrivateInodeVMObject"sv; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user