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

Function fixup_table_common

ccan/ccan/htable/htable.c:238–268  ·  view source on GitHub ↗

We want to change the common mask: this fixes up the table */

Source from the content-addressed store, hash-verified

236
237/* We want to change the common mask: this fixes up the table */
238static COLD void fixup_table_common(struct htable *ht, uintptr_t maskdiff)
239{
240 size_t i;
241 uintptr_t bitsdiff;
242
243again:
244 bitsdiff = ht->common_bits & maskdiff;
245
246 for (i = 0; i < (size_t)1 << ht->bits; i++) {
247 uintptr_t e;
248 if (!entry_is_valid(e = ht->table[i]))
249 continue;
250
251 /* Clear the bits no longer in the mask, set them as
252 * expected. */
253 e &= ~maskdiff;
254 e |= bitsdiff;
255 /* If this made it invalid, restart with more exposed */
256 if (!entry_is_valid(e)) {
257 unset_another_common_bit(ht, &maskdiff, get_raw_ptr(ht, e));
258 goto again;
259 }
260 ht->table[i] = e;
261 }
262
263 /* Take away those bits from our mask, bits and perfect bit. */
264 ht->common_mask &= ~maskdiff;
265 ht->common_bits &= ~maskdiff;
266 if (ht_perfect_mask(ht) & maskdiff)
267 ht->perfect_bitnum = NO_PERFECT_BIT;
268}
269
270/* Limited recursion */
271static void ht_add(struct htable *ht, const void *new, size_t h);

Callers 2

update_commonFunction · 0.85

Calls 4

entry_is_validFunction · 0.85
unset_another_common_bitFunction · 0.85
get_raw_ptrFunction · 0.85
ht_perfect_maskFunction · 0.85

Tested by

no test coverage detected