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

Function ht_add

ccan/ccan/htable/htable.c:290–304  ·  view source on GitHub ↗

This does not expand the hash table, that's up to caller. */

Source from the content-addressed store, hash-verified

288
289/* This does not expand the hash table, that's up to caller. */
290static void ht_add(struct htable *ht, const void *new, size_t h)
291{
292 size_t i;
293 uintptr_t perfect = ht_perfect_mask(ht);
294
295 i = hash_bucket(ht, h);
296
297 while (entry_is_valid(ht->table[i])) {
298 perfect = 0;
299 i = (i + 1) & ((1 << ht->bits)-1);
300 }
301 ht->table[i] = make_hval(ht, new, get_hash_ptr_bits(ht, h)|perfect);
302 if (!entry_is_valid(ht->table[i]))
303 update_common_fix_invalid(ht, new, h);
304}
305
306static COLD bool double_table(struct htable *ht)
307{

Callers 4

double_tableFunction · 0.85
rehash_tableFunction · 0.85
htable_add_Function · 0.85

Calls 6

ht_perfect_maskFunction · 0.85
hash_bucketFunction · 0.85
entry_is_validFunction · 0.85
make_hvalFunction · 0.85
get_hash_ptr_bitsFunction · 0.85

Tested by

no test coverage detected