mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +00:00
Kernel: Make KBuffer::try_create_with_size() return KResultOr
This allows us to use TRY() in a lot of new places.
This commit is contained in:
parent
c69035c630
commit
899cee8185
10 changed files with 31 additions and 72 deletions
|
@ -19,11 +19,8 @@ inline void DoubleBuffer::compute_lockfree_metadata()
|
|||
|
||||
KResultOr<NonnullOwnPtr<DoubleBuffer>> DoubleBuffer::try_create(size_t capacity)
|
||||
{
|
||||
auto storage = KBuffer::try_create_with_size(capacity * 2, Memory::Region::Access::ReadWrite, "DoubleBuffer");
|
||||
if (!storage)
|
||||
return ENOMEM;
|
||||
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) DoubleBuffer(capacity, storage.release_nonnull()));
|
||||
auto storage = TRY(KBuffer::try_create_with_size(capacity * 2, Memory::Region::Access::ReadWrite, "DoubleBuffer"));
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) DoubleBuffer(capacity, move(storage)));
|
||||
}
|
||||
|
||||
DoubleBuffer::DoubleBuffer(size_t capacity, NonnullOwnPtr<KBuffer> storage)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue