Tue, 16 Sep 2025 22:32:23 +0200
add error handling to cx_kv_list_set_key()
relates to #461
src/kv_list.c | file | annotate | diff | comparison | revisions |
--- a/src/kv_list.c Sat Sep 13 20:57:59 2025 +0200 +++ b/src/kv_list.c Tue Sep 16 22:32:23 2025 +0200 @@ -457,13 +457,17 @@ if (key.hash == 0) { cx_hash_murmur(&key); } + + // add the key to the map + // TODO: what happens when we are _replacing_ an existing key? + if (NULL == kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data)) { + return 1; + } + + // write the key to the list's node CxHashKey *loc_key = cx_kv_list_loc_key(kv_list, node_data); *loc_key = key; - // TODO: what happens when we are _replacing_ an existing key? - kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data); - // TODO: what happens if the map cocks up and returns NULL? - return 0; }