From c1d7662228819e1f5ed9cd5762855de8a5008507 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Fri, 21 Aug 1998 02:03:56 +0000 Subject: [PATCH] fixed off by one error in Pop() --- base/src/nsDeque.cpp | 77 +++++++++++++++++++++++++++++++++----------- base/src/nsDeque.h | 7 ++++ xpcom/ds/nsDeque.cpp | 77 +++++++++++++++++++++++++++++++++----------- xpcom/ds/nsDeque.h | 7 ++++ 4 files changed, 130 insertions(+), 38 deletions(-) diff --git a/base/src/nsDeque.cpp b/base/src/nsDeque.cpp index 3fb22a134fe..4f55467900f 100644 --- a/base/src/nsDeque.cpp +++ b/base/src/nsDeque.cpp @@ -20,6 +20,9 @@ #include "nsDeque.h" #include "nsCRT.h" +//#define _SELFTEST_DEQUE 1 +#undef _SELFTEST_DEQUE + /** * Standard constructor * @update gess4/18/98 @@ -133,9 +136,12 @@ void* nsDeque::Pop() { result=mData[mOrigin]; mData[mOrigin++]=0; //zero it out for debugging purposes. mSize--; + if(mCapacity==mOrigin) //you popped off the end, so cycle back around... + mOrigin=0; if(0==mSize) mOrigin=0; } + NS_ASSERTION(mOrigin { - nsDeque theDeque(PR_FALSE); //construct a simple one... + nsDeque theDeque(gDeallocator); //construct a simple one... - int ints[10]={100,200,300,400,500,600,700,800,900,1000}; + int ints[200]; int count=sizeof(ints)/sizeof(int); - int i=0; - for(i=0;i { - nsDeque theDeque(PR_FALSE); //construct a simple one... + nsDeque theDeque(gDeallocator); //construct a simple one... - int ints[10]={100,200,300,400,500,600,700,800,900,1000}; + int ints[200]; int count=sizeof(ints)/sizeof(int); - int i=0; - for(i=0;i