Add free function to memory manager

This commit is contained in:
Jan 2021-12-28 23:51:23 +01:00
parent ca9ee04738
commit 338de302d9
2 changed files with 14 additions and 0 deletions

View File

@ -47,6 +47,19 @@ char* MemoryManager::Dup(const char* str)
return result; return result;
} }
void MemoryManager::Free(void* data)
{
for (auto iAlloc = m_allocations.begin(); iAlloc != m_allocations.end(); ++iAlloc)
{
if (*iAlloc == data)
{
free(*iAlloc);
m_allocations.erase(iAlloc);
return;
}
}
}
void MemoryManager::Delete(void* data) void MemoryManager::Delete(void* data)
{ {
for (auto iAlloc = m_destructible.begin(); iAlloc != m_destructible.end(); ++iAlloc) for (auto iAlloc = m_destructible.begin(); iAlloc != m_destructible.end(); ++iAlloc)

View File

@ -57,5 +57,6 @@ public:
return &allocation->m_entry; return &allocation->m_entry;
} }
void Free(void* data);
void Delete(void* data); void Delete(void* data);
}; };