1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:47:45 +00:00

AK: Use kfree_sized() in AK::ByteBuffer

This commit is contained in:
Andreas Kling 2021-07-11 13:22:40 +02:00
parent 6950dd220b
commit 05a00c3978

View file

@ -41,7 +41,7 @@ public:
{ {
if (this != &other) { if (this != &other) {
if (!m_inline) if (!m_inline)
kfree(m_outline_buffer); kfree_sized(m_outline_buffer, m_outline_capacity);
move_from(move(other)); move_from(move(other));
} }
return *this; return *this;
@ -138,7 +138,7 @@ public:
void clear() void clear()
{ {
if (!m_inline) { if (!m_inline) {
kfree(m_outline_buffer); kfree_sized(m_outline_buffer, m_outline_capacity);
m_inline = true; m_inline = true;
} }
m_size = 0; m_size = 0;
@ -230,9 +230,10 @@ private:
{ {
// m_inline_buffer and m_outline_buffer are part of a union, so save the pointer // m_inline_buffer and m_outline_buffer are part of a union, so save the pointer
auto outline_buffer = m_outline_buffer; auto outline_buffer = m_outline_buffer;
auto outline_capacity = m_outline_capacity;
if (!may_discard_existing_data) if (!may_discard_existing_data)
__builtin_memcpy(m_inline_buffer, outline_buffer, size); __builtin_memcpy(m_inline_buffer, outline_buffer, size);
kfree(outline_buffer); kfree_sized(outline_buffer, outline_capacity);
m_inline = true; m_inline = true;
} }