src/kv_list.c

changeset 1382
f61119884dcd
parent 1381
ee421d6b95ef
child 1383
3db28cb1e5ec
equal deleted inserted replaced
1381:ee421d6b95ef 1382:f61119884dcd
468 // if the hash has not yet been computed, do it now 468 // if the hash has not yet been computed, do it now
469 if (key.hash == 0) { 469 if (key.hash == 0) {
470 cx_hash_murmur(&key); 470 cx_hash_murmur(&key);
471 } 471 }
472 472
473 // add the key to the map 473 // check if the key is already assigned
474 // TODO: what happens when we are _replacing_ an existing key? 474 if (kv_list->map_methods->get(&kv_list->map->map_base.base, key) != NULL) {
475 // key is already assigned, we disallow re-assignment
476 return 1;
477 }
478
479 // add the key to the map;
475 if (NULL == kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data)) { 480 if (NULL == kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data)) {
476 return 1; 481 return 1;
477 } 482 }
478 483
479 // write the key to the list's node 484 // write the key to the list's node

mercurial