AK: Don't use realloc() in AK::ByteBuffer

This class is the only reason we have to support krealloc() in the
kernel heap, something which adds a lot of complexity.

Let's move towards a simpler path and do malloc+memset in the
ByteBuffer code (where we know the sizes anyway.)
This commit is contained in:
Andreas Kling 2021-07-11 14:01:46 +02:00
parent 0718bd264c
commit 966880eb45

View file

@ -242,7 +242,9 @@ private:
u8* new_buffer;
new_capacity = kmalloc_good_size(new_capacity);
if (!m_inline) {
new_buffer = (u8*)krealloc(m_outline_buffer, new_capacity);
new_buffer = (u8*)kmalloc(new_capacity);
if (m_outline_buffer)
__builtin_memcpy(new_buffer, m_outline_buffer, min(new_capacity, m_outline_capacity));
VERIFY(new_buffer);
} else {
new_buffer = (u8*)kmalloc(new_capacity);