X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=actionlist.cc;h=f97e667a00c9a20273bbd7e146b4543d96776eda;hp=68345986f2a185c6f0931bc64763fb3df49dd0cc;hb=25d73096cfc14c655f94b01bb235cc5efd1d5696;hpb=c07babdd4135ec7c471981e436913aa7624ff643 diff --git a/actionlist.cc b/actionlist.cc index 68345986..f97e667a 100644 --- a/actionlist.cc +++ b/actionlist.cc @@ -174,15 +174,16 @@ void actionlist::removeAction(ModelAction * act) { int shiftbits = MODELCLOCKBITS; modelclock_t clock = act->get_seq_number(); allnode * ptr = &root; + allnode * oldptr; modelclock_t currindex; while(shiftbits != 0) { shiftbits -= ALLBITS; currindex = (clock >> shiftbits) & ALLMASK; - allnode * tmp = ptr->children[currindex]; - if (tmp == NULL) + oldptr = ptr; + ptr = ptr->children[currindex]; + if (ptr == NULL) return; - ptr = tmp; } sllnode * llnode = reinterpret_cast *>(((uintptr_t) ptr) & ACTMASK); @@ -205,11 +206,11 @@ void actionlist::removeAction(ModelAction * act) { if (first) { //see if previous node has same clock as us... if (llnodeprev != NULL && llnodeprev->val->get_seq_number() == clock) { - ptr->children[currindex] = reinterpret_cast(((uintptr_t)llnodeprev) | ISACT); + oldptr->children[currindex] = reinterpret_cast(((uintptr_t)llnodeprev) | ISACT); } else { //remove ourselves and go up tree - ptr->children[currindex] = NULL; - decrementCount(ptr); + oldptr->children[currindex] = NULL; + decrementCount(oldptr); } } delete llnode; @@ -226,8 +227,7 @@ void actionlist::removeAction(ModelAction * act) { void actionlist::clear() { for(uint i = 0;i < ALLNODESIZE;i++) { if (root.children[i] != NULL) { - if (!(((uintptr_t) root.children[i]) & ISACT)) - delete root.children[i]; + delete root.children[i]; root.children[i] = NULL; } } @@ -246,3 +246,16 @@ void actionlist::clear() { bool actionlist::isEmpty() { return root.count == 0; } + +/** + * Fix the parent pointer of root when root address changes (possible + * due to vector resize) + */ +void actionlist::fixupParent() +{ + for (int i = 0;i < ALLNODESIZE;i++) { + allnode * child = root.children[i]; + if (child != NULL && child->parent != &root) + child->parent = &root; + } +}