forked from metin-server/m2dev-client-src
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user