mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Use kfree_sized() in AK::StringImpl
This commit is contained in:
parent
3aabace9f5
commit
c68c3fa69c
Notes:
sideshowbarker
2024-07-18 09:20:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c68c3fa69ce
2 changed files with 8 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue