| 250 | } |
| 251 | |
| 252 | struct hashmap_entry *hashmap_remove(struct hashmap *map, |
| 253 | const struct hashmap_entry *key, |
| 254 | const void *keydata) |
| 255 | { |
| 256 | struct hashmap_entry *old; |
| 257 | struct hashmap_entry **e; |
| 258 | |
| 259 | if (!map->table) |
| 260 | return NULL; |
| 261 | e = find_entry_ptr(map, key, keydata); |
| 262 | if (!*e) |
| 263 | return NULL; |
| 264 | |
| 265 | /* remove existing entry */ |
| 266 | old = *e; |
| 267 | *e = old->next; |
| 268 | old->next = NULL; |
| 269 | |
| 270 | /* fix size and rehash if appropriate */ |
| 271 | if (map->do_count_items) { |
| 272 | map->private_size--; |
| 273 | if (map->private_size < map->shrink_at) |
| 274 | rehash(map, map->tablesize >> HASHMAP_RESIZE_BITS); |
| 275 | } |
| 276 | |
| 277 | return old; |
| 278 | } |
| 279 | |
| 280 | struct hashmap_entry *hashmap_put(struct hashmap *map, |
| 281 | struct hashmap_entry *entry) |
no test coverage detected