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

Function ht_add

ccan/ccan/htable/htable.c:278–292  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

276
277/* This does not expand the hash table, that's up to caller. */
278static void ht_add(struct htable *ht, const void *new, size_t h)
279{
280 size_t i;
281 uintptr_t perfect = ht_perfect_mask(ht);
282
283 i = hash_bucket(ht, h);
284
285 while (entry_is_valid(ht->table[i])) {
286 perfect = 0;
287 i = (i + 1) & ((1 << ht->bits)-1);
288 }
289 ht->table[i] = make_hval(ht, new, get_hash_ptr_bits(ht, h)|perfect);
290 if (!entry_is_valid(ht->table[i]))
291 update_common_fix_invalid(ht, new, h);
292}
293
294static COLD bool double_table(struct htable *ht)
295{

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