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)
This commit is contained in:
d1str4ught
2025-08-23 19:48:15 +02:00
parent 71ba5e0c9b
commit 24b1ca495b

View File

@@ -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;
}