Need to free memory
authorweiyu <weiyuluo1232@gmail.com>
Thu, 26 Sep 2019 23:57:17 +0000 (16:57 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Thu, 26 Sep 2019 23:57:17 +0000 (16:57 -0700)
classlist.h
funcnode.cc
funcnode.h

index e528a47dc40ca1a3e84eaf30202e8af87debf2be..65ac08df62da8bb64cdab4955bcdc8f5172de7d1 100644 (file)
@@ -25,6 +25,7 @@ struct bug_message;
 typedef SnapList<ModelAction *> action_list_t;
 typedef SnapList<uint32_t> func_id_list_t;
 typedef SnapList<FuncInst *> func_inst_list_t;
+typedef HashTable<FuncInst *, ModelAction *, uintptr_t, 0> inst_act_map_t;
 
 typedef HashSet<Predicate *, uintptr_t, 0, model_malloc, model_calloc, model_free> PredSet;
 typedef HSIterator<Predicate *, uintptr_t, 0, model_malloc, model_calloc, model_free> PredSetIter;
index 5b5b911436d37565b7d7913dc341471f17692397..e08ca1b850f8a0f3239bdef7fd785677acbd0745 100644 (file)
@@ -230,13 +230,14 @@ void FuncNode::update_predicate_tree(action_list_t * act_list)
        if (act_list == NULL || act_list->size() == 0)
                return;
 
-       /* map a FuncInst to the its predicate */
+       /* Map a FuncInst to the its predicate */
        HashTable<FuncInst *, Predicate *, uintptr_t, 0> inst_pred_map(128);
 
-       // number FuncInsts to detect loops
+       // Number FuncInsts to detect loops
        HashTable<FuncInst *, uint32_t, uintptr_t, 0> inst_id_map(128);
        uint32_t inst_counter = 0;
 
+       /* Only need to store the locations of read actions */
        HashTable<void *, ModelAction *, uintptr_t, 0> loc_act_map(128);
        HashTable<FuncInst *, ModelAction *, uintptr_t, 0> inst_act_map(128);
 
@@ -293,9 +294,9 @@ void FuncNode::update_predicate_tree(action_list_t * act_list)
 
                if (next_act->is_read()) {
                        loc_act_map.put(next_act->get_location(), next_act);
-                       inst_act_map.put(next_inst, next_act);
                }
 
+               inst_act_map.put(next_inst, next_act);
                inst_pred_map.put(next_inst, curr_pred);
                if (!inst_id_map.contains(next_inst))
                        inst_id_map.put(next_inst, inst_counter++);
@@ -474,6 +475,12 @@ void FuncNode::generate_predicates(Predicate ** curr_pred, FuncInst * next_inst,
                (*curr_pred)->add_child(pred);
                pred->set_parent(*curr_pred);
        }
+
+       /* Free memories allocated by infer_predicate */
+       for (uint i = 0; i < half_pred_expressions->size(); i++) {
+               struct half_pred_expr * tmp = (*half_pred_expressions)[i];
+               snapshot_free(tmp);
+       }
 }
 
 /* Amend predicates that contain no predicate expressions. Currenlty only amend with NULLITY predicates */
index 22d92835ca1c4b749b1f3211c19941bc0249e2b9..5773d79d846d79e09df531cf238cc5295ad7de28 100644 (file)
@@ -9,7 +9,6 @@
 #include "history.h"
 
 typedef ModelList<FuncInst *> func_inst_list_mt;
-typedef HashTable<FuncInst *, ModelAction *, uintptr_t, 0> inst_act_map_t;
 
 typedef enum edge_type {
        IN_EDGE, OUT_EDGE, BI_EDGE