Fixed issues and bugs

-moved system destroy functionality to System structure "destroy()" function
-now arrays are properly destroyed (with destructor calling (__xdtor))
-fixed bug which makes BlockAllocator crashing after freeing it's memory
-fixed many smaller memory leaks
This commit is contained in:
Mergul 2020-07-17 13:34:08 +02:00
parent 74179b4fc8
commit 96bbcb9956
5 changed files with 87 additions and 39 deletions

View file

@ -91,6 +91,38 @@ struct System
package:
void destroy()
{
import bubel.ecs.std : Mallocator;
disable();
if (m_destroy)
(cast(void function(void*)) m_destroy)(m_system_pointer);
if (m_name)
Mallocator.dispose(m_name);
if (m_components)
Mallocator.dispose(m_components);
if (m_excluded_components)
Mallocator.dispose(m_excluded_components);
if (m_optional_components)
Mallocator.dispose(m_optional_components);
if (jobs)
Mallocator.dispose(jobs);
if (m_read_only_components)
Mallocator.dispose(m_read_only_components);
if (m_writable_components)
Mallocator.dispose(m_writable_components);
if (m_readonly_dependencies)
Mallocator.dispose(m_readonly_dependencies);
if (m_writable_dependencies)
Mallocator.dispose(m_writable_dependencies);
if (m_event_callers)
Mallocator.dispose(m_event_callers);
if (m_system_pointer)
Mallocator.dispose(m_system_pointer);
}
struct EventCaller
{
ushort id;