mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
Kernel: Make InodeWatcher::crate API OOM safe
This commit is contained in:
parent
c8758d4faa
commit
0d50d3ed1e
3 changed files with 21 additions and 7 deletions
|
@ -25,9 +25,12 @@ struct WatchDescription {
|
|||
Inode& inode;
|
||||
unsigned event_mask;
|
||||
|
||||
static NonnullOwnPtr<WatchDescription> create(int wd, Inode& inode, unsigned event_mask)
|
||||
static KResultOr<NonnullOwnPtr<WatchDescription>> create(int wd, Inode& inode, unsigned event_mask)
|
||||
{
|
||||
return adopt_own(*new WatchDescription(wd, inode, event_mask));
|
||||
auto description = adopt_own_if_nonnull(new WatchDescription(wd, inode, event_mask));
|
||||
if (description)
|
||||
return description.release_nonnull();
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -41,7 +44,7 @@ private:
|
|||
|
||||
class InodeWatcher final : public File {
|
||||
public:
|
||||
static NonnullRefPtr<InodeWatcher> create();
|
||||
static KResultOr<NonnullRefPtr<InodeWatcher>> create();
|
||||
virtual ~InodeWatcher() override;
|
||||
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue