AK: Use kfree_sized() in AK::StringImpl

This commit is contained in:
Andreas Kling
2021-07-11 13:23:13 +02:00
parent 3aabace9f5
commit c68c3fa69c
2 changed files with 8 additions and 6 deletions

View File

@@ -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)