fix cx_kvl_map_put() returning the wrong pointer default tip

Fri, 26 Sep 2025 22:43:17 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 26 Sep 2025 22:43:17 +0200
changeset 1397
a5c7d63b064d
parent 1396
533ed620fd73

fix cx_kvl_map_put() returning the wrong pointer

relates to #461

src/kv_list.c file | annotate | diff | comparison | revisions
--- a/src/kv_list.c	Thu Sep 25 14:49:48 2025 +0200
+++ b/src/kv_list.c	Fri Sep 26 22:43:17 2025 +0200
@@ -314,7 +314,10 @@
     // copy the key to the node data
     CxHashKey *key_ptr = cx_kv_list_loc_key(kv_list, node_data);
     *key_ptr = key;
-    return map_data;
+
+    // we must return node_data here and not map_data,
+    // because the node_data is the actual element of this collection
+    return node_data;
 }
 
 void *cx_kvl_map_get(const CxMap *map, CxHashKey key) {

mercurial