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 // check if the key is already assigned |
473 // check if the key is already assigned |
474 if (kv_list->map_methods->get(&kv_list->map->map_base.base, key) != NULL) { |
474 void *existing = kv_list->map_methods->get(&kv_list->map->map_base.base, key); |
475 // key is already assigned, we disallow re-assignment |
475 if (existing == node_data) { |
|
476 return 0; // nothing to do |
|
477 } |
|
478 if (existing != NULL) { |
|
479 // the key is already assigned to another node, we disallow re-assignment |
476 return 1; |
480 return 1; |
477 } |
481 } |
478 |
482 |
479 // add the key to the map; |
483 // add the key to the map; |
480 if (NULL == kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data)) { |
484 if (NULL == kv_list->map_methods->put(&kv_list->map->map_base.base, key, node_data)) { |