Found bug... Don't update parent's list until we know we aren't going to be freed
[satune.git] / src / AST / boolean.cc
index 4ca9c404522deb2e324fc617580e8243d2159b37..978664450ba930b9eab9b61794197519a4309632 100644 (file)
@@ -37,9 +37,6 @@ BooleanPredicate::BooleanPredicate(Predicate *_predicate, Element **_inputs, uin
        encoding(this),
        inputs(_inputs, _numInputs),
        undefStatus(_undefinedStatus) {
-       for (uint i = 0; i < _numInputs; i++) {
-               _inputs[i]->parents.push(this);
-       }
 }
 
 BooleanLogic::BooleanLogic(CSolver *solver, LogicOp _op, BooleanEdge *array, uint asize) :
@@ -47,9 +44,6 @@ BooleanLogic::BooleanLogic(CSolver *solver, LogicOp _op, BooleanEdge *array, uin
        op(_op),
        replaced(false),
        inputs(array, asize) {
-       for (uint i = 0; i < asize; i++) {
-               array[i]->parents.push(this);
-       }
 }
 
 BooleanEdge cloneEdge(CSolver *solver, CloneMap *map, BooleanEdge e) {
@@ -96,3 +90,11 @@ Boolean *BooleanPredicate::clone(CSolver *solver, CloneMap *map) {
 
        return solver->applyPredicateTable(pred, array, inputs.getSize(), defstatus).getRaw();
 }
+
+void BooleanPredicate::updateParents() {
+       for(uint i=0;i < inputs.getSize(); i++) inputs.get(i)->parents.push(this);
+}
+
+void BooleanLogic::updateParents() {
+       for(uint i=0;i < inputs.getSize(); i++) inputs.get(i)->parents.push(this);
+}