221 |
221 |
222 return NULL; |
222 return NULL; |
223 } |
223 } |
224 |
224 |
225 static void *cx_hash_map_get( |
225 static void *cx_hash_map_get( |
226 CxMap const *map, |
226 const CxMap *map, |
227 CxHashKey key |
227 CxHashKey key |
228 ) { |
228 ) { |
229 // we can safely cast, because we know the map stays untouched |
229 // we can safely cast, because we know the map stays untouched |
230 return cx_hash_map_get_remove((CxMap *) map, key, false, false); |
230 return cx_hash_map_get_remove((CxMap *) map, key, false, false); |
231 } |
231 } |
236 bool destroy |
236 bool destroy |
237 ) { |
237 ) { |
238 return cx_hash_map_get_remove(map, key, true, destroy); |
238 return cx_hash_map_get_remove(map, key, true, destroy); |
239 } |
239 } |
240 |
240 |
241 static void *cx_hash_map_iter_current_entry(void const *it) { |
241 static void *cx_hash_map_iter_current_entry(const void *it) { |
242 struct cx_iterator_s const *iter = it; |
242 const struct cx_iterator_s *iter = it; |
243 // struct has to have a compatible signature |
243 // struct has to have a compatible signature |
244 return (struct cx_map_entry_s *) &(iter->kv_data); |
244 return (struct cx_map_entry_s *) &(iter->kv_data); |
245 } |
245 } |
246 |
246 |
247 static void *cx_hash_map_iter_current_key(void const *it) { |
247 static void *cx_hash_map_iter_current_key(const void *it) { |
248 struct cx_iterator_s const *iter = it; |
248 const struct cx_iterator_s *iter = it; |
249 struct cx_hash_map_element_s *elm = iter->elem_handle; |
249 struct cx_hash_map_element_s *elm = iter->elem_handle; |
250 return &elm->key; |
250 return &elm->key; |
251 } |
251 } |
252 |
252 |
253 static void *cx_hash_map_iter_current_value(void const *it) { |
253 static void *cx_hash_map_iter_current_value(const void *it) { |
254 struct cx_iterator_s const *iter = it; |
254 const struct cx_iterator_s *iter = it; |
255 struct cx_hash_map_s const *map = iter->src_handle.c; |
255 const struct cx_hash_map_s *map = iter->src_handle.c; |
256 struct cx_hash_map_element_s *elm = iter->elem_handle; |
256 struct cx_hash_map_element_s *elm = iter->elem_handle; |
257 if (map->base.collection.store_pointer) { |
257 if (map->base.collection.store_pointer) { |
258 return *(void **) elm->data; |
258 return *(void **) elm->data; |
259 } else { |
259 } else { |
260 return elm->data; |
260 return elm->data; |
261 } |
261 } |
262 } |
262 } |
263 |
263 |
264 static bool cx_hash_map_iter_valid(void const *it) { |
264 static bool cx_hash_map_iter_valid(const void *it) { |
265 struct cx_iterator_s const *iter = it; |
265 const struct cx_iterator_s *iter = it; |
266 return iter->elem_handle != NULL; |
266 return iter->elem_handle != NULL; |
267 } |
267 } |
268 |
268 |
269 static void cx_hash_map_iter_next(void *it) { |
269 static void cx_hash_map_iter_next(void *it) { |
270 struct cx_iterator_s *iter = it; |
270 struct cx_iterator_s *iter = it; |