Skip to content

Commit

Permalink
avoid use of iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ian.mcgreer%sun.com committed Apr 22, 2002
1 parent b131678 commit 6741700
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions security/nss/lib/base/list.c
Expand Up @@ -313,19 +313,23 @@ nssList_Count(nssList *list)
NSS_IMPLEMENT PRStatus
nssList_GetArray(nssList *list, void **rvArray, PRUint32 maxElements)
{
nssListIterator *iter;
void *el;
nssListElement *node;
PRUint32 i = 0;
PR_ASSERT(maxElements > 0);
iter = nssList_CreateIterator(list);
for (el = nssListIterator_Start(iter); el != NULL;
el = nssListIterator_Next(iter))
{
rvArray[i++] = el;
node = list->head;
if (!node) {
return PR_SUCCESS;
}
NSSLIST_LOCK_IF(list);
while (node) {
rvArray[i++] = node->data;
if (i == maxElements) break;
node = (nssListElement *)PR_NEXT_LINK(&node->link);
if (node == list->head) {
break;
}
}
nssListIterator_Finish(iter);
nssListIterator_Destroy(iter);
NSSLIST_UNLOCK_IF(list);
return PR_SUCCESS;
}

Expand Down

0 comments on commit 6741700

Please sign in to comment.