Skip to content

Commit 1d12dc7

Browse files
author
alecf%netscape.com
committed
from brendan's review:
oops, use NS_IF_ADDREF where apropriate also be consistent about using NS_ADDREF() on the result not part of build
1 parent 3e9aef7 commit 1d12dc7

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

xpcom/ds/nsArrayEnumerator.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ NS_NewArrayEnumerator(nsISimpleEnumerator* *result,
8787
nsSimpleArrayEnumerator* enumer = new nsSimpleArrayEnumerator(array);
8888
if (enumer == nsnull)
8989
return NS_ERROR_OUT_OF_MEMORY;
90-
NS_ADDREF(enumer);
9190
*result = enumer;
91+
NS_ADDREF(*result);
9292
return NS_OK;
9393
}
9494

@@ -131,7 +131,7 @@ nsCOMArrayEnumerator::~nsCOMArrayEnumerator()
131131
{
132132
// only release the entries that we haven't visited yet
133133
while (mIndex < mArraySize) {
134-
NS_RELEASE(mValueArray[mIndex++]);
134+
NS_IF_RELEASE(mValueArray[mIndex++]);
135135
}
136136
}
137137

@@ -142,11 +142,6 @@ nsCOMArrayEnumerator::HasMoreElements(PRBool* aResult)
142142
if (! aResult)
143143
return NS_ERROR_NULL_POINTER;
144144

145-
if (!mValueArray) {
146-
*aResult = PR_FALSE;
147-
return NS_OK;
148-
}
149-
150145
*aResult = (mIndex < mArraySize);
151146
return NS_OK;
152147
}
@@ -158,11 +153,6 @@ nsCOMArrayEnumerator::GetNext(nsISupports** aResult)
158153
if (! aResult)
159154
return NS_ERROR_NULL_POINTER;
160155

161-
if (!mValueArray) {
162-
*aResult = nsnull;
163-
return NS_OK;
164-
}
165-
166156
if (mIndex >= mArraySize)
167157
return NS_ERROR_UNEXPECTED;
168158

0 commit comments

Comments
 (0)