Simulation mem leak - create hard block mappings (#997)
* mappings array pointers hasn't been freed when they were unuseful
* change the location of added code
* set mappings items and array to NULL and free them
* set mappings pointers to NULL after freeing them
* remove extra free mappings
diff --git a/ODIN_II/SRC/read_blif.cpp b/ODIN_II/SRC/read_blif.cpp
index ae2c6b6..5cb6351 100644
--- a/ODIN_II/SRC/read_blif.cpp
+++ b/ODIN_II/SRC/read_blif.cpp
@@ -537,6 +537,16 @@
// Index the mappings in a hard_block_ports struct.
hard_block_ports *ports = get_hard_block_ports(mappings, count);
+ for (i = 0; i < count; i++)
+ {
+ vtr::free(mappings[i]);
+ mappings[i] = NULL;
+ }
+
+ vtr::free(mappings);
+ mappings = NULL;
+
+
// Look up the model in the models cache.
hard_block_model *model = NULL;
if ((subcircuit_name != NULL) && (!(model = get_hard_block_model(subcircuit_name, ports, models))))
@@ -642,8 +652,7 @@
free_hard_block_ports(ports);
mapping_index->destroy_free_items();
- delete mapping_index;
- vtr::free(mappings);
+ delete mapping_index;
vtr::free(names);