Lines Matching refs:lh
102 void lh_free(_LHASH *lh) {
106 if (lh == NULL) {
110 for (i = 0; i < lh->num_buckets; i++) {
111 for (n = lh->buckets[i]; n != NULL; n = next) {
117 OPENSSL_free(lh->buckets);
118 OPENSSL_free(lh);
121 size_t lh_num_items(const _LHASH *lh) { return lh->num_items; }
126 * element of |lh->buckets|, otherwise it returns a pointer to the |next|
130 static LHASH_ITEM **get_next_ptr_and_hash(const _LHASH *lh, uint32_t *out_hash,
132 const uint32_t hash = lh->hash(data);
139 ret = &lh->buckets[hash % lh->num_buckets];
141 if (lh->comp(cur->data, data) == 0) {
150 void *lh_retrieve(const _LHASH *lh, const void *data) {
153 next_ptr = get_next_ptr_and_hash(lh, NULL, data);
163 * redistributes the existing items into it before making it |lh->buckets| and
165 static void lh_rebucket(_LHASH *lh, const size_t new_num_buckets) {
180 for (i = 0; i < lh->num_buckets; i++) {
181 for (cur = lh->buckets[i]; cur != NULL; cur = next) {
189 OPENSSL_free(lh->buckets);
191 lh->num_buckets = new_num_buckets;
192 lh->buckets = new_buckets;
196 static void lh_maybe_resize(_LHASH *lh) {
199 if (lh->callback_depth > 0) {
204 assert(lh->num_buckets >= kMinNumBuckets);
205 avg_chain_length = lh->num_items / lh->num_buckets;
208 const size_t new_num_buckets = lh->num_buckets * 2;
210 if (new_num_buckets > lh->num_buckets) {
211 lh_rebucket(lh, new_num_buckets);
214 lh->num_buckets > kMinNumBuckets) {
215 size_t new_num_buckets = lh->num_buckets / 2;
221 lh_rebucket(lh, new_num_buckets);
225 int lh_insert(_LHASH *lh, void **old_data, void *data) {
230 next_ptr = get_next_ptr_and_hash(lh, &hash, data);
251 lh->num_items++;
252 lh_maybe_resize(lh);
257 void *lh_delete(_LHASH *lh, const void *data) {
260 next_ptr = get_next_ptr_and_hash(lh, NULL, data);
272 lh->num_items--;
273 lh_maybe_resize(lh);
278 static void lh_doall_internal(_LHASH *lh, void (*no_arg_func)(void *),
283 if (lh == NULL) {
287 if (lh->callback_depth < UINT_MAX) {
289 lh->callback_depth++;
292 for (i = 0; i < lh->num_buckets; i++) {
293 for (cur = lh->buckets[i]; cur != NULL; cur = next) {
303 if (lh->callback_depth < UINT_MAX) {
304 lh->callback_depth--;
310 lh_maybe_resize(lh);
313 void lh_doall(_LHASH *lh, void (*func)(void *)) {
314 lh_doall_internal(lh, func, NULL, NULL);
317 void lh_doall_arg(_LHASH *lh, void (*func)(void *, void *), void *arg) {
318 lh_doall_internal(lh, NULL, func, arg);