mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-25 11:48:06 +00:00
Kernel: Plumb OOM propagation through Custody factory
Modify the Custody::create(..) API so it has the ability to propagate OOM back to the caller.
This commit is contained in:
parent
fb93535419
commit
0b7395848a
Notes:
sideshowbarker
2024-07-18 18:23:22 +09:00
Author: https://github.com/bgianfo
Commit: 0b7395848a
Pull-request: https://github.com/SerenityOS/serenity/pull/7004
3 changed files with 27 additions and 7 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Heap/SlabAllocator.h>
|
||||
#include <Kernel/KResult.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -19,9 +20,13 @@ namespace Kernel {
|
|||
class Custody : public RefCounted<Custody> {
|
||||
MAKE_SLAB_ALLOCATED(Custody)
|
||||
public:
|
||||
static NonnullRefPtr<Custody> create(Custody* parent, const StringView& name, Inode& inode, int mount_flags)
|
||||
static KResultOr<NonnullRefPtr<Custody>> create(Custody* parent, const StringView& name, Inode& inode, int mount_flags)
|
||||
{
|
||||
return adopt_ref(*new Custody(parent, name, inode, mount_flags));
|
||||
auto custody = new Custody(parent, name, inode, mount_flags);
|
||||
if (!custody)
|
||||
return ENOMEM;
|
||||
|
||||
return adopt_ref(*custody);
|
||||
}
|
||||
|
||||
~Custody();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue