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

Function double_table

ccan/ccan/htable/htable.c:294–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294static COLD bool double_table(struct htable *ht)
295{
296 unsigned int i;
297 size_t oldnum = (size_t)1 << ht->bits;
298 uintptr_t *oldtable, e;
299
300 oldtable = ht->table;
301 ht->table = htable_alloc(ht, sizeof(size_t) << (ht->bits+1));
302 if (!ht->table) {
303 ht->table = oldtable;
304 return false;
305 }
306 ht->bits++;
307
308 /* If we lost our "perfect bit", get it back now. */
309 if (ht->perfect_bitnum == NO_PERFECT_BIT && ht->common_mask) {
310 for (i = 0; i < sizeof(ht->common_mask) * CHAR_BIT; i++) {
311 if (ht->common_mask & ((size_t)2 << i)) {
312 ht->perfect_bitnum = i;
313 break;
314 }
315 }
316 }
317
318 if (oldtable != &ht->common_bits) {
319 for (i = 0; i < oldnum; i++) {
320 if (entry_is_valid(e = oldtable[i])) {
321 void *p = get_raw_ptr(ht, e);
322 ht_add(ht, p, ht->rehash(p, ht->priv));
323 }
324 }
325 htable_free(ht, oldtable);
326 }
327 ht->deleted = 0;
328
329 (void)htable_debug(ht, HTABLE_LOC);
330 return true;
331}
332
333static COLD void rehash_table(struct htable *ht)
334{

Callers 1

htable_add_Function · 0.85

Calls 3

entry_is_validFunction · 0.85
get_raw_ptrFunction · 0.85
ht_addFunction · 0.85

Tested by

no test coverage detected