diff -r ae61523bce20 -r 2f71f4ee247a application/pwd.c --- a/application/pwd.c Thu Oct 03 18:52:51 2024 +0200 +++ b/application/pwd.c Sun Oct 06 18:18:04 2024 +0200 @@ -32,7 +32,6 @@ #include "pwd.h" -#include #include #include @@ -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);