| 343 | } |
| 344 | |
| 345 | static COLD void rehash_table(struct htable *ht) |
| 346 | { |
| 347 | size_t start, i; |
| 348 | uintptr_t e, perfect = ht_perfect_mask(ht); |
| 349 | |
| 350 | /* Beware wrap cases: we need to start from first empty bucket. */ |
| 351 | for (start = 0; ht->table[start]; start++); |
| 352 | |
| 353 | for (i = 0; i < (size_t)1 << ht->bits; i++) { |
| 354 | size_t h = (i + start) & ((1 << ht->bits)-1); |
| 355 | e = ht->table[h]; |
| 356 | if (!e) |
| 357 | continue; |
| 358 | if (e == HTABLE_DELETED) |
| 359 | ht->table[h] = 0; |
| 360 | else if (!(e & perfect)) { |
| 361 | void *p = get_raw_ptr(ht, e); |
| 362 | ht->table[h] = 0; |
| 363 | ht_add(ht, p, ht->rehash(p, ht->priv)); |
| 364 | } |
| 365 | } |
| 366 | ht->deleted = 0; |
| 367 | (void)htable_debug(ht, HTABLE_LOC); |
| 368 | } |
| 369 | |
| 370 | /* We stole some bits, now we need to put them back... */ |
| 371 | static COLD void update_common(struct htable *ht, const void *p) |
no test coverage detected