Lines Matching refs:map
67 default_delete_func(const struct keymap *map, in default_delete_func() argument
113 struct keymap *map = MALLOC_STRUCT(keymap); in util_new_keymap() local
114 if (!map) in util_new_keymap()
117 map->cso = cso_hash_create(); in util_new_keymap()
118 if (!map->cso) { in util_new_keymap()
119 FREE(map); in util_new_keymap()
123 map->max_entries = maxEntries; in util_new_keymap()
124 map->num_entries = 0; in util_new_keymap()
125 map->key_size = keySize; in util_new_keymap()
126 map->delete_func = deleteFunc ? deleteFunc : default_delete_func; in util_new_keymap()
128 return map; in util_new_keymap()
138 util_delete_keymap(struct keymap *map, void *user) in util_delete_keymap() argument
140 util_keymap_remove_all(map, user); in util_delete_keymap()
141 cso_hash_delete(map->cso); in util_delete_keymap()
142 FREE(map); in util_delete_keymap()
147 hash_table_find_iter(const struct keymap *map, const void *key, in hash_table_find_iter() argument
153 iter = cso_hash_find(map->cso, key_hash); in hash_table_find_iter()
156 if (!memcmp(item->key, key, map->key_size)) in hash_table_find_iter()
166 hash_table_find_item(const struct keymap *map, const void *key, in hash_table_find_item() argument
169 struct cso_hash_iter iter = hash_table_find_iter(map, key, key_hash); in hash_table_find_item()
188 util_keymap_insert(struct keymap *map, const void *key, in util_keymap_insert() argument
195 assert(map); in util_keymap_insert()
196 if (!map) in util_keymap_insert()
199 key_hash = hash(key, map->key_size); in util_keymap_insert()
201 item = hash_table_find_item(map, key, key_hash); in util_keymap_insert()
204 map->delete_func(map, item->key, item->value, user); in util_keymap_insert()
213 item->key = mem_dup(key, map->key_size); in util_keymap_insert()
216 iter = cso_hash_insert(map->cso, key_hash, item); in util_keymap_insert()
222 map->num_entries++; in util_keymap_insert()
232 util_keymap_lookup(const struct keymap *map, const void *key) in util_keymap_lookup() argument
237 assert(map); in util_keymap_lookup()
238 if (!map) in util_keymap_lookup()
241 key_hash = hash(key, map->key_size); in util_keymap_lookup()
243 item = hash_table_find_item(map, key, key_hash); in util_keymap_lookup()
257 util_keymap_remove(struct keymap *map, const void *key, void *user) in util_keymap_remove() argument
263 assert(map); in util_keymap_remove()
264 if (!map) in util_keymap_remove()
267 key_hash = hash(key, map->key_size); in util_keymap_remove()
269 iter = hash_table_find_iter(map, key, key_hash); in util_keymap_remove()
277 map->delete_func(map, item->key, item->value, user); in util_keymap_remove()
281 map->num_entries--; in util_keymap_remove()
283 cso_hash_erase(map->cso, iter); in util_keymap_remove()
292 util_keymap_remove_all(struct keymap *map, void *user) in util_keymap_remove_all() argument
297 assert(map); in util_keymap_remove_all()
298 if (!map) in util_keymap_remove_all()
301 iter = cso_hash_first_node(map->cso); in util_keymap_remove_all()
304 cso_hash_take(map->cso, cso_hash_iter_key(iter)); in util_keymap_remove_all()
305 map->delete_func(map, item->key, item->value, user); in util_keymap_remove_all()
308 iter = cso_hash_first_node(map->cso); in util_keymap_remove_all()
314 util_keymap_info(const struct keymap *map) in util_keymap_info() argument
317 (void *) map, map->num_entries, map->max_entries); in util_keymap_info()