mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
Kernel: Tidy up AnonymousFile construction a bit
- Rename create() => try_create() - Use adopt_nonnull_ref_or_enomem()
This commit is contained in:
parent
9a1fdb523f
commit
4012099338
Notes:
sideshowbarker
2024-07-18 04:43:25 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/40120993380
@ -13,9 +13,9 @@ namespace Kernel {
|
||||
|
||||
class AnonymousFile final : public File {
|
||||
public:
|
||||
static RefPtr<AnonymousFile> create(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
static KResultOr<NonnullRefPtr<AnonymousFile>> try_create(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
}
|
||||
|
||||
virtual ~AnonymousFile() override;
|
||||
|
@ -33,10 +33,10 @@ KResultOr<FlatPtr> Process::sys$anon_create(size_t size, int options)
|
||||
if (maybe_vmobject.is_error())
|
||||
return maybe_vmobject.error();
|
||||
|
||||
auto anon_file = AnonymousFile::create(maybe_vmobject.release_value());
|
||||
if (!anon_file)
|
||||
return ENOMEM;
|
||||
auto description_or_error = FileDescription::try_create(*anon_file);
|
||||
auto anon_file_or_error = AnonymousFile::try_create(maybe_vmobject.release_value());
|
||||
if (anon_file_or_error.is_error())
|
||||
return anon_file_or_error.error();
|
||||
auto description_or_error = FileDescription::try_create(anon_file_or_error.release_value());
|
||||
if (description_or_error.is_error())
|
||||
return description_or_error.error();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user