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

Function fixup_table_common

ccan/ccan/htable/htable.c:226–256  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

224
225/* We want to change the common mask: this fixes up the table */
226static COLD void fixup_table_common(struct htable *ht, uintptr_t maskdiff)
227{
228 size_t i;
229 uintptr_t bitsdiff;
230
231again:
232 bitsdiff = ht->common_bits & maskdiff;
233
234 for (i = 0; i < (size_t)1 << ht->bits; i++) {
235 uintptr_t e;
236 if (!entry_is_valid(e = ht->table[i]))
237 continue;
238
239 /* Clear the bits no longer in the mask, set them as
240 * expected. */
241 e &= ~maskdiff;
242 e |= bitsdiff;
243 /* If this made it invalid, restart with more exposed */
244 if (!entry_is_valid(e)) {
245 unset_another_common_bit(ht, &maskdiff, get_raw_ptr(ht, e));
246 goto again;
247 }
248 ht->table[i] = e;
249 }
250
251 /* Take away those bits from our mask, bits and perfect bit. */
252 ht->common_mask &= ~maskdiff;
253 ht->common_bits &= ~maskdiff;
254 if (ht_perfect_mask(ht) & maskdiff)
255 ht->perfect_bitnum = NO_PERFECT_BIT;
256}
257
258/* Limited recursion */
259static 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