summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/StringImpl.cpp5
-rw-r--r--AK/StringImpl.h9
2 files changed, 8 insertions, 6 deletions
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> 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<StringImpl> {
public:
static NonnullRefPtr<StringImpl> 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<StringImpl*>(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<StringImpl> : Formatter<StringView> {
void format(FormatBuilder& builder, const StringImpl& value)