# HG changeset patch # User Mike Becker # Date 1758054743 -7200 # Node ID 0698e573936f48163960d7464af8015e8aedba92 # Parent e0ba5e20e77a1575f5184582d62a4b4596a55daa add error handling to cx_kv_list_set_key() relates to #461 diff -r e0ba5e20e77a -r 0698e573936f src/kv_list.c --- 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; }