fixed memory leak in proper way

This commit is contained in:
Anis 2016-02-25 18:26:15 +01:00
parent 27112c468a
commit 7418fbfbbd

View file

@ -214,12 +214,22 @@ Profiler::~Profiler()
void Profiler::reset() void Profiler::reset()
{ {
mEnabled = false; // in case we're in a profiler call. mEnabled = false; // in case we're in a profiler call.
while (mProfileList) ProfilerData * head = mProfileList;
ProfilerData * curr = head;
while ( curr )
{ {
free(mProfileList); head = curr->mNextProfilerData;
mProfileList = NULL; free( curr );
if ( head )
curr = head;
else
curr = NULL;
} }
mProfileList = NULL;
for(ProfilerRootData *walk = ProfilerRootData::sRootList; walk; walk = walk->mNextRoot) for(ProfilerRootData *walk = ProfilerRootData::sRootList; walk; walk = walk->mNextRoot)
{ {
walk->mFirstProfilerData = 0; walk->mFirstProfilerData = 0;