101 elm = elm->next; |
101 elm = elm->next; |
102 } |
102 } |
103 |
103 |
104 if (elm != NULL && elm->key.hash == hash && elm->key.len == key.len && |
104 if (elm != NULL && elm->key.hash == hash && elm->key.len == key.len && |
105 memcmp(elm->key.data, key.data, key.len) == 0) { |
105 memcmp(elm->key.data, key.data, key.len) == 0) { |
106 // overwrite existing element |
106 // overwrite existing element, but call destructors first |
|
107 cx_invoke_destructor(map, elm->data); |
107 if (map->collection.store_pointer) { |
108 if (map->collection.store_pointer) { |
108 memcpy(elm->data, &value, sizeof(void *)); |
109 memcpy(elm->data, &value, sizeof(void *)); |
109 } else { |
110 } else { |
110 memcpy(elm->data, value, map->collection.elem_size); |
111 memcpy(elm->data, value, map->collection.elem_size); |
111 } |
112 } |