Lines Matching refs:lh
101 void lh_free(_LHASH *lh) { in lh_free() argument
105 if (lh == NULL) { in lh_free()
109 for (i = 0; i < lh->num_buckets; i++) { in lh_free()
110 for (n = lh->buckets[i]; n != NULL; n = next) { in lh_free()
116 OPENSSL_free(lh->buckets); in lh_free()
117 OPENSSL_free(lh); in lh_free()
120 size_t lh_num_items(const _LHASH *lh) { return lh->num_items; } in lh_num_items() argument
129 static LHASH_ITEM **get_next_ptr_and_hash(const _LHASH *lh, uint32_t *out_hash, in get_next_ptr_and_hash() argument
131 const uint32_t hash = lh->hash(data); in get_next_ptr_and_hash()
138 ret = &lh->buckets[hash % lh->num_buckets]; in get_next_ptr_and_hash()
140 if (lh->comp(cur->data, data) == 0) { in get_next_ptr_and_hash()
149 void *lh_retrieve(const _LHASH *lh, const void *data) { in lh_retrieve() argument
152 next_ptr = get_next_ptr_and_hash(lh, NULL, data); in lh_retrieve()
164 static void lh_rebucket(_LHASH *lh, const size_t new_num_buckets) { in lh_rebucket() argument
179 for (i = 0; i < lh->num_buckets; i++) { in lh_rebucket()
180 for (cur = lh->buckets[i]; cur != NULL; cur = next) { in lh_rebucket()
188 OPENSSL_free(lh->buckets); in lh_rebucket()
190 lh->num_buckets = new_num_buckets; in lh_rebucket()
191 lh->buckets = new_buckets; in lh_rebucket()
195 static void lh_maybe_resize(_LHASH *lh) { in lh_maybe_resize() argument
198 if (lh->callback_depth > 0) { in lh_maybe_resize()
203 assert(lh->num_buckets >= kMinNumBuckets); in lh_maybe_resize()
204 avg_chain_length = lh->num_items / lh->num_buckets; in lh_maybe_resize()
207 const size_t new_num_buckets = lh->num_buckets * 2; in lh_maybe_resize()
209 if (new_num_buckets > lh->num_buckets) { in lh_maybe_resize()
210 lh_rebucket(lh, new_num_buckets); in lh_maybe_resize()
213 lh->num_buckets > kMinNumBuckets) { in lh_maybe_resize()
214 size_t new_num_buckets = lh->num_buckets / 2; in lh_maybe_resize()
220 lh_rebucket(lh, new_num_buckets); in lh_maybe_resize()
224 int lh_insert(_LHASH *lh, void **old_data, void *data) { in lh_insert() argument
229 next_ptr = get_next_ptr_and_hash(lh, &hash, data); in lh_insert()
250 lh->num_items++; in lh_insert()
251 lh_maybe_resize(lh); in lh_insert()
256 void *lh_delete(_LHASH *lh, const void *data) { in lh_delete() argument
259 next_ptr = get_next_ptr_and_hash(lh, NULL, data); in lh_delete()
271 lh->num_items--; in lh_delete()
272 lh_maybe_resize(lh); in lh_delete()
277 static void lh_doall_internal(_LHASH *lh, void (*no_arg_func)(void *), in lh_doall_internal() argument
282 if (lh == NULL) { in lh_doall_internal()
286 if (lh->callback_depth < UINT_MAX) { in lh_doall_internal()
288 lh->callback_depth++; in lh_doall_internal()
291 for (i = 0; i < lh->num_buckets; i++) { in lh_doall_internal()
292 for (cur = lh->buckets[i]; cur != NULL; cur = next) { in lh_doall_internal()
302 if (lh->callback_depth < UINT_MAX) { in lh_doall_internal()
303 lh->callback_depth--; in lh_doall_internal()
309 lh_maybe_resize(lh); in lh_doall_internal()
312 void lh_doall(_LHASH *lh, void (*func)(void *)) { in lh_doall() argument
313 lh_doall_internal(lh, func, NULL, NULL); in lh_doall()
316 void lh_doall_arg(_LHASH *lh, void (*func)(void *, void *), void *arg) { in lh_doall_arg() argument
317 lh_doall_internal(lh, NULL, func, arg); in lh_doall_arg()