mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
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:
parent
0718bd264c
commit
966880eb45
1 changed files with 3 additions and 1 deletions
|
@ -242,7 +242,9 @@ private:
|
||||||
u8* new_buffer;
|
u8* new_buffer;
|
||||||
new_capacity = kmalloc_good_size(new_capacity);
|
new_capacity = kmalloc_good_size(new_capacity);
|
||||||
if (!m_inline) {
|
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);
|
VERIFY(new_buffer);
|
||||||
} else {
|
} else {
|
||||||
new_buffer = (u8*)kmalloc(new_capacity);
|
new_buffer = (u8*)kmalloc(new_capacity);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue