small changes
[c11tester.git] / cyclegraph.cc
index bb481e1374c6ad19f91a9a9eb27828517b775919..1d9533f4ba9b6f2fa61ae0018bb36dc22de5abcc 100644 (file)
@@ -70,8 +70,7 @@ void CycleGraph::addNodeEdge(CycleNode *fromnode, CycleNode *tonode, bool forcee
         * If the fromnode has a rmwnode, we should
         * follow its RMW chain to add an edge at the end.
         */
-       while (fromnode->getRMW()) {
-               CycleNode *nextnode = fromnode->getRMW();
+       while (CycleNode * nextnode = fromnode->getRMW()) {
                if (nextnode == tonode)
                        break;
                fromnode = nextnode;
@@ -297,6 +296,10 @@ void CycleGraph::freeAction(const ModelAction * act) {
                CycleNode *dst = cn->edges[i];
                dst->removeInEdge(cn);
        }
+       for(unsigned int i=0;i<cn->inedges.size();i++) {
+               CycleNode *src = cn->inedges[i];
+               src->removeEdge(cn);
+       }
        delete cn;
 }
 
@@ -325,6 +328,16 @@ void CycleNode::removeInEdge(CycleNode *src) {
        }
 }
 
+void CycleNode::removeEdge(CycleNode *dst) {
+       for(unsigned int i=0;i < edges.size();i++) {
+               if (edges[i] == dst) {
+                       edges[i] = edges[edges.size()-1];
+                       edges.pop_back();
+                       break;
+               }
+       }
+}
+
 /**
  * @param i The index of the edge to return
  * @returns The CycleNode edge indexed by i