mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
Kernel: Tidy up Memory::AddressSpace construction
- Return KResultOr<T> in places - Propagate errors - Use TRY()
This commit is contained in:
parent
0cf65cf7ec
commit
83fed5b2de
6 changed files with 16 additions and 30 deletions
|
@ -15,14 +15,10 @@
|
|||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
OwnPtr<AddressSpace> AddressSpace::try_create(AddressSpace const* parent)
|
||||
KResultOr<NonnullOwnPtr<AddressSpace>> AddressSpace::try_create(AddressSpace const* parent)
|
||||
{
|
||||
auto page_directory = PageDirectory::try_create_for_userspace(parent ? &parent->page_directory().range_allocator() : nullptr);
|
||||
if (!page_directory)
|
||||
return {};
|
||||
auto space = adopt_own_if_nonnull(new (nothrow) AddressSpace(page_directory.release_nonnull()));
|
||||
if (!space)
|
||||
return {};
|
||||
auto page_directory = TRY(PageDirectory::try_create_for_userspace(parent ? &parent->page_directory().range_allocator() : nullptr));
|
||||
auto space = TRY(adopt_nonnull_own_or_enomem(new (nothrow) AddressSpace(page_directory)));
|
||||
space->page_directory().set_space({}, *space);
|
||||
return space;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue