dav/pwd.c

branch
ucx-3.1
changeset 816
839fefbdedc7
parent 789
378b5ab86f77
--- a/dav/pwd.c	Sat Apr 20 13:01:58 2024 +0200
+++ b/dav/pwd.c	Thu May 23 22:35:45 2024 +0200
@@ -32,7 +32,6 @@
 
 #include "pwd.h"
 
-#include <cx/buffer.h>
 #include <cx/utils.h>
 #include <cx/hash_map.h>
 
@@ -141,12 +140,11 @@
       
     char *id = NULL;
     CxList *locations = cxLinkedListCreateSimple(CX_STORE_POINTERS);
-    locations->simple_destructor = free;
+    cxDefineDestructor(locations, free);
     
     // get id (required)
     int ret = 0;
     if(readval(in, &id, FALSE)) {
-        ret = 1;
         // get locations
         char *location = NULL;
         while((ret = readval(in, &location, TRUE)) == 1) {
@@ -175,7 +173,6 @@
     }
     
     char *id = NULL;
-    char *location = NULL;
     char *user = NULL;
     char *password = NULL;
     
@@ -190,39 +187,33 @@
     }
     
     if(id) free(id);
-    if(location) free(location);
     if(user) free(user);
     if(password) free(password);
     
     return ret;
 }
 
-static int remove_list_entries(PwdStore *s, const char *id) {
-    int ret = 0;
-    
-    CxList *loc_entry = NULL;
-    CxList *noloc_entry = NULL;
-    
-    CxMutIterator i = cxListMutIterator(s->locations);
+static void remove_list_entries(PwdStore *s, const char *id) {
+    CxIterator i = cxListMutIterator(s->locations);
     cx_foreach(PwdIndexEntry*, ie, i) {
         if(!strcmp(ie->id, id)) {
             cxIteratorFlagRemoval(i);
-            // TODO: break loop
+            cxIteratorNext(i);
+            break;
         }
     }
     i = cxListMutIterator(s->noloc);
     cx_foreach(PwdIndexEntry*, ie, i) {
         if(!strcmp(ie->id, id)) {
             cxIteratorFlagRemoval(i);
-            // TODO: break loop
+            cxIteratorNext(i);
+            break;
         }
     }
-    
-    return ret;
 }
 
 void pwdstore_remove_entry(PwdStore *s, const char *id) {
-    while(remove_list_entries(s, id)) {}
+    remove_list_entries(s, id);
     
     CxHashKey key = cx_hash_key_str(id);
     PwdIndexEntry *i = cxMapRemoveAndGet(s->index, key);
@@ -331,7 +322,7 @@
 }
 
 void pwdstore_free(PwdStore* p) {
-    p->ids->simple_destructor = (cx_destructor_func)pwdstore_free_entry;
+    cxDefineDestructor(p->ids, pwdstore_free_entry);
     cxMapDestroy(p->ids);
     
     cxListDestroy(p->locations);

mercurial