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<ModelAction *> * llnode = reinterpret_cast<sllnode<ModelAction *> *>(((uintptr_t) ptr) & ACTMASK);
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<allnode *>(((uintptr_t)llnodeprev) | ISACT);
+ oldptr->children[currindex] = reinterpret_cast<allnode *>(((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;
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;
}
}
bool actionlist::isEmpty() {
return root.count == 0;
}
+
+/**
+ * Fix the parent pointer of root when root address changes (possible
+ * due to vector<action_list_t> 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;
+ }
+}