src/kv_list.c

changeset 1382
f61119884dcd
parent 1381
ee421d6b95ef
child 1383
3db28cb1e5ec
--- a/src/kv_list.c	Sat Sep 20 12:19:49 2025 +0200
+++ b/src/kv_list.c	Sat Sep 20 12:27:36 2025 +0200
@@ -470,8 +470,13 @@
         cx_hash_murmur(&key);
     }
 
-    // add the key to the map
-    // TODO: what happens when we are _replacing_ an existing key?
+    // check if the key is already assigned
+    if (kv_list->map_methods->get(&kv_list->map->map_base.base, key) != NULL) {
+        // key is already assigned, we disallow re-assignment
+        return 1;
+    }
+
+    // add the key to the map;
     if (NULL == kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data)) {
         return 1;
     }

mercurial