mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
Kernel: Move KBufferBuilder to the fallible KBuffer API
KBufferBuilder::build() now returns an OwnPtr<KBuffer> and can fail. Clients of the API have been updated to handle that situation.
This commit is contained in:
parent
d936d86332
commit
8e79bde2b7
18 changed files with 121 additions and 100 deletions
|
@ -33,19 +33,21 @@ namespace Kernel {
|
|||
|
||||
inline bool KBufferBuilder::can_append(size_t size) const
|
||||
{
|
||||
bool has_space = ((m_size + size) < m_buffer.size());
|
||||
if (!m_buffer)
|
||||
return false;
|
||||
bool has_space = ((m_size + size) < m_buffer->size());
|
||||
ASSERT(has_space);
|
||||
return has_space;
|
||||
}
|
||||
|
||||
KBuffer KBufferBuilder::build()
|
||||
OwnPtr<KBuffer> KBufferBuilder::build()
|
||||
{
|
||||
m_buffer.set_size(m_size);
|
||||
return m_buffer;
|
||||
m_buffer->set_size(m_size);
|
||||
return m_buffer.release_nonnull();
|
||||
}
|
||||
|
||||
KBufferBuilder::KBufferBuilder()
|
||||
: m_buffer(KBuffer::create_with_size(4 * MiB, Region::Access::Read | Region::Access::Write))
|
||||
: m_buffer(KBuffer::try_create_with_size(4 * MiB, Region::Access::Read | Region::Access::Write))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue