glave: cleanup mem_info list as it shrinks during tracing
authorJon Ashburn <jon@lunarg.com>
Thu, 26 Feb 2015 18:45:28 +0000 (11:45 -0700)
committerJon Ashburn <jon@lunarg.com>
Thu, 26 Feb 2015 18:45:28 +0000 (11:45 -0700)
glave-generate.py

index f284418..bb99ea0 100755 (executable)
@@ -886,9 +886,14 @@ class Subcommand(object):
         hf_body.append('        entry->size = 0;')
         hf_body.append('        entry->handle = NULL;')
         hf_body.append('')
-        hf_body.append('        //TODO go thru array and set numEntrys based on last valid entry g_memInfo.numEntrys--;')
         hf_body.append('        if (entry == g_memInfo.pLastMapped)')
         hf_body.append('            g_memInfo.pLastMapped = NULL;')
+        hf_body.append('        // adjust numEntrys to be last valid entry in list')
+        hf_body.append('        do {')
+        hf_body.append('            entry =  g_memInfo.pEntrys + g_memInfo.numEntrys - 1;')
+        hf_body.append('            if (entry->valid == FALSE)')
+        hf_body.append('                g_memInfo.numEntrys--;')
+        hf_body.append('        } while ((entry->valid == FALSE) && (g_memInfo.numEntrys > 0));')
         hf_body.append('        if (g_memInfo.numEntrys == 0)')
         hf_body.append('            delete_mem_info();')
         hf_body.append('    }')