1
Fork 0
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:
Andreas Kling 2021-09-07 15:15:08 +02:00
parent c69035c630
commit 899cee8185
10 changed files with 31 additions and 72 deletions

View file

@ -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)