| 331 | } |
| 332 | |
| 333 | static COLD void rehash_table(struct htable *ht) |
| 334 | { |
| 335 | size_t start, i; |
| 336 | uintptr_t e, perfect = ht_perfect_mask(ht); |
| 337 | |
| 338 | /* Beware wrap cases: we need to start from first empty bucket. */ |
| 339 | for (start = 0; ht->table[start]; start++); |
| 340 | |
| 341 | for (i = 0; i < (size_t)1 << ht->bits; i++) { |
| 342 | size_t h = (i + start) & ((1 << ht->bits)-1); |
| 343 | e = ht->table[h]; |
| 344 | if (!e) |
| 345 | continue; |
| 346 | if (e == HTABLE_DELETED) |
| 347 | ht->table[h] = 0; |
| 348 | else if (!(e & perfect)) { |
| 349 | void *p = get_raw_ptr(ht, e); |
| 350 | ht->table[h] = 0; |
| 351 | ht_add(ht, p, ht->rehash(p, ht->priv)); |
| 352 | } |
| 353 | } |
| 354 | ht->deleted = 0; |
| 355 | (void)htable_debug(ht, HTABLE_LOC); |
| 356 | } |
| 357 | |
| 358 | /* We stole some bits, now we need to put them back... */ |
| 359 | static COLD void update_common(struct htable *ht, const void *p) |
no test coverage detected