1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:14:58 +00:00

Plug leaks in SynthFS::remove_file().

The process spawn stress test can now run forever. :^)
This commit is contained in:
Andreas Kling 2018-12-28 03:09:45 +01:00
parent 3f3535213b
commit ab72666f48
3 changed files with 39 additions and 2 deletions

View file

@ -1,6 +1,21 @@
#include "StringImpl.h"
#include "StdLibExtras.h"
#include "kmalloc.h"
#include "HashTable.h"
#ifdef DEBUG_STRINGIMPL
unsigned g_stringimpl_count;
static HashTable<StringImpl*>* g_all_live_stringimpls;
void dump_all_stringimpls()
{
unsigned i = 0;
for (auto& it : *g_all_live_stringimpls) {
dbgprintf("%u: \"%s\"\n", i, (*it).characters());
++i;
}
}
#endif
namespace AK {
@ -9,6 +24,10 @@ static StringImpl* s_the_empty_stringimpl = nullptr;
void StringImpl::initialize_globals()
{
s_the_empty_stringimpl = nullptr;
#ifdef DEBUG_STRINGIMPL
g_stringimpl_count = 0;
g_all_live_stringimpls = new HashTable<StringImpl*>;
#endif
}
StringImpl& StringImpl::the_empty_stringimpl()
@ -18,8 +37,22 @@ StringImpl& StringImpl::the_empty_stringimpl()
return *s_the_empty_stringimpl;
}
StringImpl::StringImpl(ConstructWithInlineBufferTag, size_t length)
: m_length(length)
, m_characters(m_inline_buffer)
{
#ifdef DEBUG_STRINGIMPL
++g_stringimpl_count;
g_all_live_stringimpls->set(this);
#endif
}
StringImpl::~StringImpl()
{
#ifdef DEBUG_STRINGIMPL
--g_stringimpl_count;
g_all_live_stringimpls->remove(this);
#endif
}
static inline size_t allocationSizeForStringImpl(size_t length)