MCPcopy Create free account
hub / github.com/ElementsProject/lightning / rehash_table

Function rehash_table

ccan/ccan/htable/htable.c:345–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345static 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... */
371static COLD void update_common(struct htable *ht, const void *p)

Callers 1

htable_add_Function · 0.85

Calls 3

ht_perfect_maskFunction · 0.85
get_raw_ptrFunction · 0.85
ht_addFunction · 0.85

Tested by

no test coverage detected