From 21e011a6423e0e4e5b6fb5743bf9065871057c7e Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" Date: Tue, 8 Aug 2006 17:09:01 +0000 Subject: [PATCH] Bug 319024 - Password manager does not remember data - regression from bug 316414 part 1 - observer enumerators need to hand out the strong-ref nsIObserver-implementing object, not the nsIWeakReference-implementing object, r=darin Original committer: bsmedberg%covad.net Original revision: 1.11 Original date: 2005/12/13 21:12:38 --- xpcom/glue/nsArrayEnumerator.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/xpcom/glue/nsArrayEnumerator.cpp b/xpcom/glue/nsArrayEnumerator.cpp index 7094362f4188..243ba8657f34 100644 --- a/xpcom/glue/nsArrayEnumerator.cpp +++ b/xpcom/glue/nsArrayEnumerator.cpp @@ -112,8 +112,7 @@ public: } // specialized operator to make sure we make room for mValues - void* operator new (size_t size, const nsCOMArray_base& aArray, - PRBool aReverse) CPP_THROW_NEW; + void* operator new (size_t size, const nsCOMArray_base& aArray) CPP_THROW_NEW; void operator delete(void* ptr) { ::operator delete(ptr); } @@ -173,8 +172,7 @@ nsCOMArrayEnumerator::GetNext(nsISupports** aResult) } void* -nsCOMArrayEnumerator::operator new (size_t size, const nsCOMArray_base& aArray, - PRBool aReverse) +nsCOMArrayEnumerator::operator new (size_t size, const nsCOMArray_base& aArray) CPP_THROW_NEW { // create enough space such that mValueArray points to a large @@ -186,20 +184,15 @@ nsCOMArrayEnumerator::operator new (size_t size, const nsCOMArray_base& aArray, nsCOMArrayEnumerator * result = NS_STATIC_CAST(nsCOMArrayEnumerator*, ::operator new(size)); - if (!result) - return result; - // now need to copy over the values, and addref each one // now this might seem like a lot of work, but we're actually just // doing all our AddRef's ahead of time since GetNext() doesn't // need to AddRef() on the way out + PRUint32 i; PRUint32 max = result->mArraySize = aArray.Count(); - PRUint32 cur = aReverse ? max - 1 : 0; - PRUint32 incr = aReverse ? -1 : 1; - - for (PRUint32 i = 0; i < max; ++i, cur += incr) { - result->mValueArray[cur] = aArray[i]; - NS_IF_ADDREF(result->mValueArray[cur]); + for (i = 0; imValueArray[i] = aArray[i]; + NS_IF_ADDREF(result->mValueArray[i]); } return result; @@ -207,11 +200,9 @@ nsCOMArrayEnumerator::operator new (size_t size, const nsCOMArray_base& aArray, extern NS_COM nsresult NS_NewArrayEnumerator(nsISimpleEnumerator* *aResult, - const nsCOMArray_base& aArray, - PRBool aReverse) + const nsCOMArray_base& aArray) { - nsCOMArrayEnumerator *enumerator = - new (aArray, aReverse) nsCOMArrayEnumerator(); + nsCOMArrayEnumerator *enumerator = new (aArray) nsCOMArrayEnumerator(); if (!enumerator) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(*aResult = enumerator);