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

Function rehash_table

ccan/ccan/htable/htable.c:333–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333static 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... */
359static 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