libidav/pwdstore.c

changeset 101
7b3a3130be44
parent 66
eee1f3092844
equal deleted inserted replaced
100:d2bd73d28ff1 101:7b3a3130be44
222 } 222 }
223 223
224 if(ret) { 224 if(ret) {
225 pwdstore_put_index(p, id, locations); 225 pwdstore_put_index(p, id, locations);
226 if(cxListSize(locations) == 0) { 226 if(cxListSize(locations) == 0) {
227 cxListDestroy(locations); 227 cxListFree(locations);
228 } 228 }
229 } else { 229 } else {
230 if(id) free(id); 230 if(id) free(id);
231 cxListDestroy(locations); 231 cxListFree(locations);
232 } 232 }
233 233
234 return ret; 234 return ret;
235 } 235 }
236 236
283 283
284 void pwdstore_remove_entry(PwdStore *s, const char *id) { 284 void pwdstore_remove_entry(PwdStore *s, const char *id) {
285 remove_list_entries(s, id); 285 remove_list_entries(s, id);
286 286
287 CxHashKey key = cx_hash_key_str(id); 287 CxHashKey key = cx_hash_key_str(id);
288 PwdIndexEntry *i = cxMapRemoveAndGet(s->index, key); 288 PwdIndexEntry *i = NULL;
289 PwdEntry *e = cxMapRemoveAndGet(s->ids, key); 289 cxMapRemoveAndGet(s->index, key, &i);
290 PwdEntry *e = NULL;
291 cxMapRemoveAndGet(s->ids, key, &e);
290 292
291 if(i) { 293 if(i) {
292 if(i->locations) { 294 if(i->locations) {
293 cxListDestroy(i->locations); 295 cxListFree(i->locations);
294 } 296 }
295 free(i->id); 297 free(i->id);
296 free(i); 298 free(i);
297 } 299 }
298 if(e) { 300 if(e) {
394 free(e); 396 free(e);
395 } 397 }
396 398
397 void pwdstore_free(PwdStore* p) { 399 void pwdstore_free(PwdStore* p) {
398 cxDefineDestructor(p->ids, pwdstore_free_entry); 400 cxDefineDestructor(p->ids, pwdstore_free_entry);
399 cxMapDestroy(p->ids); 401 cxMapFree(p->ids);
400 402
401 cxListDestroy(p->locations); 403 cxListFree(p->locations);
402 404
403 if(p->content) { 405 if(p->content) {
404 cxBufferFree(p->content); 406 cxBufferFree(p->content);
405 } 407 }
406 408

mercurial