src/kv_list.c

changeset 1376
0698e573936f
parent 1375
e0ba5e20e77a
equal deleted inserted replaced
1375:e0ba5e20e77a 1376:0698e573936f
455 } 455 }
456 // if the hash has not yet been computed, do it now 456 // if the hash has not yet been computed, do it now
457 if (key.hash == 0) { 457 if (key.hash == 0) {
458 cx_hash_murmur(&key); 458 cx_hash_murmur(&key);
459 } 459 }
460
461 // add the key to the map
462 // TODO: what happens when we are _replacing_ an existing key?
463 if (NULL == kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data)) {
464 return 1;
465 }
466
467 // write the key to the list's node
460 CxHashKey *loc_key = cx_kv_list_loc_key(kv_list, node_data); 468 CxHashKey *loc_key = cx_kv_list_loc_key(kv_list, node_data);
461 *loc_key = key; 469 *loc_key = key;
462 470
463 // TODO: what happens when we are _replacing_ an existing key?
464 kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data);
465 // TODO: what happens if the map cocks up and returns NULL?
466
467 return 0; 471 return 0;
468 } 472 }
469 473
470 int cx_kv_list_remove_key(CxList *list, size_t index, CxHashKey key) { 474 int cx_kv_list_remove_key(CxList *list, size_t index, CxHashKey key) {
471 return -1; 475 return -1;

mercurial