--- a/dav/pwd.c Sat Oct 12 09:53:32 2019 +0200 +++ b/dav/pwd.c Sat Oct 12 11:17:11 2019 +0200 @@ -191,6 +191,58 @@ return ret; } +static int remove_list_entries(PwdStore *s, const char *id) { + int ret = 0; + + UcxList *loc_entry = NULL; + UcxList *noloc_entry = NULL; + UCX_FOREACH(elm, s->locations) { + PwdIndexEntry *ie = elm->data; + if(!strcmp(ie->id, id)) { + loc_entry = elm; + ret = 1; + break; + } + } + UCX_FOREACH(elm, s->noloc) { + PwdIndexEntry *ie = elm->data; + if(!strcmp(ie->id, id)) { + noloc_entry = elm; + ret = 1; + break; + } + } + + if(loc_entry) { + s->locations = ucx_list_remove(s->locations, loc_entry); + } + if(noloc_entry) { + s->noloc = ucx_list_remove(s->noloc, noloc_entry); + } + + return ret; +} + +void pwdstore_remove_entry(PwdStore *s, const char *id) { + while(remove_list_entries(s, id)) {} + + PwdIndexEntry *i = ucx_map_cstr_remove(s->index, id); + PwdEntry *e = ucx_map_cstr_remove(s->ids, id); + + if(i) { + ucx_list_free_content(i->locations, free); + ucx_list_free(i->locations); + free(i->id); + free(i); + } + if(e) { + free(e->id); + free(e->user); + free(e->password); + free(e); + } +} + int pwdstore_getindex(PwdStore *s) { uint32_t netindexlen;