Browse Source

generate_c_testbench: add a warning if there is no allocation call before a de-allocation one

Ioannis Koutras 12 years ago
parent
commit
6a2b7fe647
1 changed files with 6 additions and 3 deletions
  1. 6 3
      scripts/generate_c_testbench.py

+ 6 - 3
scripts/generate_c_testbench.py

@@ -22,9 +22,12 @@ def parse_memory_trace(input_file, output_file):
             output_file.write(new_line)
         free_match = free_pattern.match(line)
         if free_match:
-            new_line = ''.join(['    free(var_', active_memory_requests[free_match.group(1)], ');\n'])
-            del active_memory_requests[free_match.group(1)]
-            output_file.write(new_line)
+            if free_match.group(1) in active_memory_requests:
+                new_line = ''.join(['    free(var_', active_memory_requests[free_match.group(1)], ');\n'])
+                del active_memory_requests[free_match.group(1)]
+                output_file.write(new_line)
+            else:
+                print "Warning: free call without an actual malloc"
 
     input_file.close()