summaryrefslogtreecommitdiffhomepage
path: root/src/orderedmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/orderedmap.c')
-rw-r--r--src/orderedmap.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/orderedmap.c b/src/orderedmap.c
index 4902be0..1818e27 100644
--- a/src/orderedmap.c
+++ b/src/orderedmap.c
@@ -81,14 +81,19 @@ char* orderedmap_find(struct orderedmap *o, const char *key) {
int orderedmap_remove(struct orderedmap *o, const char *key) {
size_t i;
char *lk;
- htab_value *lv, *v = htab_find(o->map, key);
+ char *sk;
+ char **sv;
+ htab_value *lv, *v = htab_find2(o->map, key, &sk);
if(!v) return 0;
- htab_delete(o->map, key);
+ sv = sblist_get(o->values, v->n);
+ free(*sv);
sblist_delete(o->values, v->n);
i = 0;
while((i = htab_next(o->map, i, &lk, &lv))) {
if(lv->n > v->n) lv->n--;
}
+ htab_delete(o->map, key);
+ free(sk);
return 1;
}