about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/tools/rcfile.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c
index 9ea85a1a..1622e32b 100644
--- a/src/tools/rcfile.c
+++ b/src/tools/rcfile.c
@@ -183,15 +183,14 @@ static void clearParam(my_params_t* param)
 static void addParam(const char* name, my_params_t* param)
 {
     khint_t k;
-    int ret;
     k = kh_get(params, params, name);
-    const char* oldkey = (k!=kh_end(params))?kh_key(params, k):NULL;
-    k = kh_put(params, params, strdup(name), &ret);
+    if(k==kh_end(params)) {
+        int ret;
+        k = kh_put(params, params, strdup(name), &ret);
+    } else {
+        clearParam(&kh_value(params, k));
+    }
     my_params_t *p = &kh_value(params, k);
-    if(!ret)
-        clearParam(p);
-    if(oldkey)
-        free((void*)oldkey);
     memcpy(p, param, sizeof(my_params_t));
 }