Fri, 27 May 2022 12:28:35 +0200
fix kv-pair not initialized
src/hash_map.c | file | annotate | diff | comparison | revisions |
--- a/src/hash_map.c Fri May 27 11:39:50 2022 +0200 +++ b/src/hash_map.c Fri May 27 12:28:35 2022 +0200 @@ -335,13 +335,14 @@ if (map->size > 0) { struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; - struct cx_hash_map_element_s *elem = NULL; - for (; elem == NULL; iter.slot++) { - elem = hash_map->buckets[iter.slot]; + struct cx_hash_map_element_s *elm = NULL; + for (; elm == NULL; iter.slot++) { + elm = hash_map->buckets[iter.slot]; } - iter.elem_handle = elem; - iter.kv_data.key = NULL; - iter.kv_data.value = NULL; + iter.elem_handle = elm; + iter.kv_data.key = &elm->key; + // TODO: pointer to data if this map is storing copies + iter.kv_data.value = elm->data; } else { iter.elem_handle = NULL; iter.kv_data.key = NULL;