瀏覽代碼

fixed memory leak in proper way

Anis 9 年之前
父節點
當前提交
7418fbfbbd
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13 3
      Engine/source/platform/profiler.cpp

+ 13 - 3
Engine/source/platform/profiler.cpp

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