mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
Kernel: Move ProcFS API towards OOM safety
This commit is contained in:
parent
23c021912e
commit
cbe1e05771
Notes:
sideshowbarker
2024-07-18 17:02:11 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/cbe1e057713 Pull-request: https://github.com/SerenityOS/serenity/pull/7624
@ -234,9 +234,9 @@ struct ProcFSInodeData : public FileDescriptionData {
|
||||
RefPtr<KBufferImpl> buffer;
|
||||
};
|
||||
|
||||
NonnullRefPtr<ProcFS> ProcFS::create()
|
||||
RefPtr<ProcFS> ProcFS::create()
|
||||
{
|
||||
return adopt_ref(*new ProcFS);
|
||||
return adopt_ref_if_nonnull(new ProcFS);
|
||||
}
|
||||
|
||||
ProcFS::~ProcFS()
|
||||
@ -1015,10 +1015,12 @@ RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
|
||||
// and if that fails we cannot return this instance anymore and just
|
||||
// create a new one.
|
||||
if (it->value->try_ref())
|
||||
return adopt_ref(*it->value);
|
||||
return adopt_ref_if_nonnull(it->value);
|
||||
// We couldn't ref it, so just create a new one and replace the entry
|
||||
}
|
||||
auto inode = adopt_ref(*new ProcFSInode(const_cast<ProcFS&>(*this), inode_id.index()));
|
||||
auto inode = adopt_ref_if_nonnull(new ProcFSInode(const_cast<ProcFS&>(*this), inode_id.index()));
|
||||
if (!inode)
|
||||
return {};
|
||||
auto result = m_inodes.set(inode_id.index().value(), inode.ptr());
|
||||
VERIFY(result == ((it == m_inodes.end()) ? AK::HashSetResult::InsertedNewEntry : AK::HashSetResult::ReplacedExistingEntry));
|
||||
return inode;
|
||||
|
@ -24,7 +24,7 @@ class ProcFS final : public FS {
|
||||
|
||||
public:
|
||||
virtual ~ProcFS() override;
|
||||
static NonnullRefPtr<ProcFS> create();
|
||||
static RefPtr<ProcFS> create();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user