152 |
152 |
153 int ucx_map_put(UcxMap *map, UcxKey key, void *data) { |
153 int ucx_map_put(UcxMap *map, UcxKey key, void *data) { |
154 UcxAllocator *allocator = map->allocator; |
154 UcxAllocator *allocator = map->allocator; |
155 |
155 |
156 if (key.hash == 0) { |
156 if (key.hash == 0) { |
157 key.hash = ucx_hash(key.data, key.len); |
157 key.hash = ucx_hash((const char*)key.data, key.len); |
158 } |
158 } |
159 |
159 |
160 struct UcxMapKey mapkey; |
160 struct UcxMapKey mapkey; |
161 mapkey.hash = key.hash; |
161 mapkey.hash = key.hash; |
162 |
162 |
201 return 0; |
201 return 0; |
202 } |
202 } |
203 |
203 |
204 static void* ucx_map_get_and_remove(UcxMap *map, UcxKey key, int remove) { |
204 static void* ucx_map_get_and_remove(UcxMap *map, UcxKey key, int remove) { |
205 if(key.hash == 0) { |
205 if(key.hash == 0) { |
206 key.hash = ucx_hash((char*)key.data, key.len); |
206 key.hash = ucx_hash((const char*)key.data, key.len); |
207 } |
207 } |
208 |
208 |
209 size_t slot = key.hash%map->size; |
209 size_t slot = key.hash%map->size; |
210 UcxMapElement *elm = map->map[slot]; |
210 UcxMapElement *elm = map->map[slot]; |
211 UcxMapElement *pelm = NULL; |
211 UcxMapElement *pelm = NULL; |