From 338de302d91cc796f72ea436e4ede748ff3f047f Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 28 Dec 2021 23:51:23 +0100 Subject: [PATCH] Add free function to memory manager --- src/Utils/Utils/MemoryManager.cpp | 13 +++++++++++++ src/Utils/Utils/MemoryManager.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/Utils/Utils/MemoryManager.cpp b/src/Utils/Utils/MemoryManager.cpp index 759d28b3..31582fb1 100644 --- a/src/Utils/Utils/MemoryManager.cpp +++ b/src/Utils/Utils/MemoryManager.cpp @@ -47,6 +47,19 @@ char* MemoryManager::Dup(const char* str) 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) { for (auto iAlloc = m_destructible.begin(); iAlloc != m_destructible.end(); ++iAlloc) diff --git a/src/Utils/Utils/MemoryManager.h b/src/Utils/Utils/MemoryManager.h index d3301bfe..ec008e4d 100644 --- a/src/Utils/Utils/MemoryManager.h +++ b/src/Utils/Utils/MemoryManager.h @@ -57,5 +57,6 @@ public: return &allocation->m_entry; } + void Free(void* data); void Delete(void* data); }; \ No newline at end of file