mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
Kernel: Make Kernel::VMObject allocation functions return KResultOr
This makes for nicer handling of errors compared to checking whether a RefPtr is null. Additionally, this will give way to return different types of errors in the future.
This commit is contained in:
parent
61c0e3ca92
commit
4bfd6e41b9
Notes:
sideshowbarker
2024-07-18 05:39:32 +09:00
Author: https://github.com/sin-ack
Commit: 4bfd6e41b9
Pull-request: https://github.com/SerenityOS/serenity/pull/9434
Reviewed-by: https://github.com/awesomekling
26 changed files with 194 additions and 122 deletions
|
@ -29,11 +29,11 @@ KResultOr<FlatPtr> Process::sys$anon_create(size_t size, int options)
|
|||
if (new_fd_or_error.is_error())
|
||||
return new_fd_or_error.error();
|
||||
auto new_fd = new_fd_or_error.release_value();
|
||||
auto vmobject = Memory::AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve);
|
||||
if (!vmobject)
|
||||
return ENOMEM;
|
||||
auto maybe_vmobject = Memory::AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve);
|
||||
if (maybe_vmobject.is_error())
|
||||
return maybe_vmobject.error();
|
||||
|
||||
auto anon_file = AnonymousFile::create(vmobject.release_nonnull());
|
||||
auto anon_file = AnonymousFile::create(maybe_vmobject.release_value());
|
||||
if (!anon_file)
|
||||
return ENOMEM;
|
||||
auto description_or_error = FileDescription::create(*anon_file);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue