diff options
author | ian.mcgreer%sun.com <devnull@localhost> | 2002-04-22 20:44:07 +0000 |
---|---|---|
committer | ian.mcgreer%sun.com <devnull@localhost> | 2002-04-22 20:44:07 +0000 |
commit | 8ed1f118c8827ac56934dcba5f6a798cd84a420b (patch) | |
tree | fa326263f478dc00f7a08102be43066109e87993 | |
parent | dcb5d011c93c16a3c208b2bbd593e0148f6a7813 (diff) | |
download | nss-hg-8ed1f118c8827ac56934dcba5f6a798cd84a420b.tar.gz |
avoid use of iterator
-rw-r--r-- | security/nss/lib/base/list.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/security/nss/lib/base/list.c b/security/nss/lib/base/list.c index f4ef49b70..ae601d50c 100644 --- a/security/nss/lib/base/list.c +++ b/security/nss/lib/base/list.c @@ -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; } |