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

Function htable_init_sized

ccan/ccan/htable/htable.c:101–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101bool htable_init_sized(struct htable *ht,
102 size_t (*rehash)(const void *, void *),
103 void *priv, size_t expect)
104{
105 htable_init(ht, rehash, priv);
106
107 /* Don't go insane with sizing. */
108 for (ht->bits = 1; ht_max(ht) < expect; ht->bits++) {
109 if (ht->bits == 30)
110 break;
111 }
112
113 ht->table = htable_alloc(ht, sizeof(size_t) << ht->bits);
114 if (!ht->table) {
115 ht->table = &ht->common_bits;
116 return false;
117 }
118 (void)htable_debug(ht, HTABLE_LOC);
119 return true;
120}
121
122void htable_clear(struct htable *ht)
123{

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 2

htable_initFunction · 0.85
ht_maxFunction · 0.85

Tested by 2

mainFunction · 0.68
mainFunction · 0.68