mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Use kfree_sized() in AK::StringImpl
This commit is contained in:
@@ -37,11 +37,6 @@ StringImpl::~StringImpl()
|
|||||||
FlyString::did_destroy_impl({}, *this);
|
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)
|
NonnullRefPtr<StringImpl> StringImpl::create_uninitialized(size_t length, char*& buffer)
|
||||||
{
|
{
|
||||||
VERIFY(length);
|
VERIFY(length);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ enum ShouldChomp {
|
|||||||
Chomp
|
Chomp
|
||||||
};
|
};
|
||||||
|
|
||||||
|
size_t allocation_size_for_stringimpl(size_t length);
|
||||||
|
|
||||||
class StringImpl : public RefCounted<StringImpl> {
|
class StringImpl : public RefCounted<StringImpl> {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<StringImpl> create_uninitialized(size_t length, char*& buffer);
|
static NonnullRefPtr<StringImpl> create_uninitialized(size_t length, char*& buffer);
|
||||||
@@ -34,7 +36,7 @@ public:
|
|||||||
|
|
||||||
void operator delete(void* ptr)
|
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();
|
static StringImpl& the_empty_stringimpl();
|
||||||
@@ -100,6 +102,11 @@ private:
|
|||||||
char m_inline_buffer[0];
|
char m_inline_buffer[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline size_t allocation_size_for_stringimpl(size_t length)
|
||||||
|
{
|
||||||
|
return sizeof(StringImpl) + (sizeof(char) * length) + sizeof(char);
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct Formatter<StringImpl> : Formatter<StringView> {
|
struct Formatter<StringImpl> : Formatter<StringView> {
|
||||||
void format(FormatBuilder& builder, const StringImpl& value)
|
void format(FormatBuilder& builder, const StringImpl& value)
|
||||||
|
|||||||
Reference in New Issue
Block a user