src/hash_map.c

changeset 1114
ad5eeb256242
parent 1111
78eeeb950883
child 1115
6db21dee4929
equal deleted inserted replaced
1113:dce04550fbef 1114:ad5eeb256242
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 }

mercurial