X-Git-Url: http://git.pk910.de/?p=srvx.git;a=blobdiff_plain;f=src%2Fdict-splay.c;h=42bb9025778342b5107b190ee4f70cc0ac04b55c;hp=38117cdb7eac59500baf748ccf2b98ff071f26c9;hb=35ffb2ad774fac945c200d06a30174fe676d94bb;hpb=47311a53d46d39b96842b2da83eb03caf089d9da diff --git a/src/dict-splay.c b/src/dict-splay.c index 38117cd..42bb902 100644 --- a/src/dict-splay.c +++ b/src/dict-splay.c @@ -202,7 +202,7 @@ dict_insert(dict_t dict, const char *key, void *data) int dict_remove2(dict_t dict, const char *key, int no_dispose) { - struct dict_node *new_root; + struct dict_node *new_root, *old_root; if (!dict->root) return 0; @@ -220,13 +220,14 @@ dict_remove2(dict_t dict, const char *key, int no_dispose) if (dict->first == dict->root) dict->first = dict->first->next; if (dict->root->next) dict->root->next->prev = dict->root->prev; if (dict->last == dict->root) dict->last = dict->last->prev; + old_root = dict->root; + dict->root = new_root; + dict->count--; if (no_dispose) { - free(dict->root); + free(old_root); } else { - dict_dispose_node(dict->root, dict->free_keys, dict->free_data); + dict_dispose_node(old_root, dict->free_keys, dict->free_data); } - dict->root = new_root; - dict->count--; return 1; }