1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 11:15:10 +00:00

Kernel: Remove KBufferBuilder's can_expand restriction

KBufferBuilder is always allowed to expand if it wants to. This
restriction was added a long time ago when it was unsafe to allocate
VM while generating ProcFS contents.
This commit is contained in:
Andreas Kling 2021-07-20 15:16:25 +02:00
parent fef835de7f
commit f85b94e6d4
2 changed files with 2 additions and 6 deletions

View file

@ -15,8 +15,6 @@ inline bool KBufferBuilder::check_expand(size_t size)
return false;
if ((m_size + size) < m_buffer->capacity())
return true;
if (!m_can_expand)
return false;
if (Checked<size_t>::addition_would_overflow(m_size, size))
return false;
size_t new_buffer_size = m_size + size;
@ -42,9 +40,8 @@ OwnPtr<KBuffer> KBufferBuilder::build()
return try_make<KBuffer>(move(m_buffer));
}
KBufferBuilder::KBufferBuilder(bool can_expand)
KBufferBuilder::KBufferBuilder()
: m_buffer(KBufferImpl::try_create_with_size(4 * MiB, Region::Access::Read | Region::Access::Write))
, m_can_expand(can_expand)
{
}

View file

@ -16,7 +16,7 @@ class KBufferBuilder {
public:
using OutputType = KBuffer;
explicit KBufferBuilder(bool can_expand = false);
KBufferBuilder();
KBufferBuilder(KBufferBuilder&&) = default;
~KBufferBuilder() = default;
@ -50,7 +50,6 @@ private:
RefPtr<KBufferImpl> m_buffer;
size_t m_size { 0 };
bool m_can_expand { false };
};
}