mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
Kernel: Make it possible for KBufferBuilder creation to fail
This patch adds KBufferBuilder::try_create() and treats it like anything else that can fail. And so, failure to allocate the initial internal buffer of the builder will now propagate an ENOMEM to the caller. :^)
This commit is contained in:
parent
be613b9ef6
commit
300402cc14
9 changed files with 30 additions and 13 deletions
|
@ -46,8 +46,14 @@ OwnPtr<KBuffer> KBufferBuilder::build()
|
|||
return move(m_buffer);
|
||||
}
|
||||
|
||||
KBufferBuilder::KBufferBuilder()
|
||||
: m_buffer(KBuffer::try_create_with_size(4 * MiB, Memory::Region::Access::ReadWrite).release_value())
|
||||
KResultOr<KBufferBuilder> KBufferBuilder::try_create()
|
||||
{
|
||||
auto buffer = TRY(KBuffer::try_create_with_size(4 * MiB, Memory::Region::Access::ReadWrite));
|
||||
return KBufferBuilder { move(buffer) };
|
||||
}
|
||||
|
||||
KBufferBuilder::KBufferBuilder(NonnullOwnPtr<KBuffer> buffer)
|
||||
: m_buffer(move(buffer))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue