diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index 3af1ce1eac..0b27d60c49 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -37,11 +37,6 @@ StringImpl::~StringImpl() FlyString::did_destroy_impl({}, *this); } -static inline size_t allocation_size_for_stringimpl(size_t length) -{ - return sizeof(StringImpl) + (sizeof(char) * length) + sizeof(char); -} - NonnullRefPtr StringImpl::create_uninitialized(size_t length, char*& buffer) { VERIFY(length); diff --git a/AK/StringImpl.h b/AK/StringImpl.h index 219abdd539..6e07c06919 100644 --- a/AK/StringImpl.h +++ b/AK/StringImpl.h @@ -20,6 +20,8 @@ enum ShouldChomp { Chomp }; +size_t allocation_size_for_stringimpl(size_t length); + class StringImpl : public RefCounted { public: static NonnullRefPtr create_uninitialized(size_t length, char*& buffer); @@ -34,7 +36,7 @@ public: void operator delete(void* ptr) { - kfree(ptr); + kfree_sized(ptr, allocation_size_for_stringimpl(static_cast(ptr)->m_length)); } static StringImpl& the_empty_stringimpl(); @@ -100,6 +102,11 @@ private: char m_inline_buffer[0]; }; +inline size_t allocation_size_for_stringimpl(size_t length) +{ + return sizeof(StringImpl) + (sizeof(char) * length) + sizeof(char); +} + template<> struct Formatter : Formatter { void format(FormatBuilder& builder, const StringImpl& value)