From 24b1ca495bfd8a686d953a18691dd54d35312331 Mon Sep 17 00:00:00 2001 From: d1str4ught <> Date: Sat, 23 Aug 2025 19:48:15 +0200 Subject: [PATCH] pool FreeAll and Destroy fixed there could have been memory leaks and undefined behaviors if the objects destructors were not called and the object it pooled contained objects that are constructed (like std::string) --- src/EterLib/Pool.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/EterLib/Pool.h b/src/EterLib/Pool.h index ae44c6e..4741638 100644 --- a/src/EterLib/Pool.h +++ b/src/EterLib/Pool.h @@ -22,6 +22,8 @@ class CDynamicPool void Destroy() { + FreeAll(); + for (T* p : m_Chunks) ::free(p); @@ -54,6 +56,11 @@ class CDynamicPool void FreeAll() { + for (T* p : m_Data) { + if (std::find(m_Free.begin(), m_Free.end(), p) == m_Free.end()) { + p->~T(); + } + } m_Free = m_Data; }