avoid use of iterator
authorian.mcgreer%sun.com
Mon, 22 Apr 2002 20:44:07 +0000
changeset 3034 850b8ead7b1be88ea5f241e278f4c4ecaa376c7c
parent 3033 900ff3fdbe88dddb33a593633b2c8eec88b25ab5
child 3036 253aacbcd4845b542aaab1c492ae2b3814bfb651
push idunknown
push userunknown
push dateunknown
avoid use of iterator
security/nss/lib/base/list.c
--- a/security/nss/lib/base/list.c
+++ b/security/nss/lib/base/list.c
@@ -308,29 +308,33 @@ NSS_IMPLEMENT PRUint32
 nssList_Count(nssList *list)
 {
     return list->count;
 }
 
 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;
 }
 
 NSS_IMPLEMENT nssList *
 nssList_Clone(nssList *list)
 {
     nssList *rvList;
     nssListElement *node;