From: bdemsky Date: Mon, 25 Oct 2004 15:52:42 +0000 (+0000) Subject: Had a bug in our implementation. If the list empties when the tail is at the last... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=commitdiff_plain;h=bfa6572a30b82fb1a430cb78e79a55ed93e4640a;hp=b8581255abd288fa590fe18d7424aeb82d945675 Had a bug in our implementation. If the list empties when the tail is at the last position in a ListNode, the tail gets zeroed. This should never happen. --- diff --git a/Repair/RepairCompiler/MCC/Runtime/SimpleHash.cc b/Repair/RepairCompiler/MCC/Runtime/SimpleHash.cc index 07f8a12..6281d15 100755 --- a/Repair/RepairCompiler/MCC/Runtime/SimpleHash.cc +++ b/Repair/RepairCompiler/MCC/Runtime/SimpleHash.cc @@ -119,10 +119,12 @@ void WorkList::pop() { int newoffset=tailoffset+4; struct ListNode *ptr=tail; if (newoffset>=WLISTSIZE) { - newoffset-=WLISTSIZE; - struct ListNode *oldptr=ptr; - ptr=ptr->next; - free(oldptr); + if (newoffset!=WLISTSIZE||head!=tail) { + newoffset-=WLISTSIZE; + struct ListNode *oldptr=ptr; + ptr=ptr->next; + free(oldptr); + } } tail=ptr; tailoffset=newoffset; @@ -136,6 +138,10 @@ void WorkList::add(int id,int type, int lvalue, int rvalue) { } headoffset=0; head=head->next; + if (tailoffset==WLISTSIZE) { /* roll the tail over also */ + tailoffset=0; + tail=tail->next; + } } head->data[headoffset++]=id; head->data[headoffset++]=type;