From bfa6572a30b82fb1a430cb78e79a55ed93e4640a Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 25 Oct 2004 15:52:42 +0000 Subject: [PATCH] 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. --- Repair/RepairCompiler/MCC/Runtime/SimpleHash.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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; -- 2.34.1