| 230 | } |
| 231 | |
| 232 | void hashmap_add(struct hashmap *map, struct hashmap_entry *entry) |
| 233 | { |
| 234 | unsigned int b; |
| 235 | |
| 236 | if (!map->table) |
| 237 | alloc_table(map, HASHMAP_INITIAL_SIZE); |
| 238 | |
| 239 | b = bucket(map, entry); |
| 240 | /* add entry */ |
| 241 | entry->next = map->table[b]; |
| 242 | map->table[b] = entry; |
| 243 | |
| 244 | /* fix size and rehash if appropriate */ |
| 245 | if (map->do_count_items) { |
| 246 | map->private_size++; |
| 247 | if (map->private_size > map->grow_at) |
| 248 | rehash(map, map->tablesize << HASHMAP_RESIZE_BITS); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | struct hashmap_entry *hashmap_remove(struct hashmap *map, |
| 253 | const struct hashmap_entry *key, |