• Home
  • Raw
  • Download

Lines Matching refs:lh

43 static int expand(OPENSSL_LHASH *lh);
44 static void contract(OPENSSL_LHASH *lh);
45 static OPENSSL_LH_NODE **getrn(OPENSSL_LHASH *lh, const void *data, unsigned long *rhash);
76 void OPENSSL_LH_free(OPENSSL_LHASH *lh) in OPENSSL_LH_free() argument
81 if (lh == NULL) in OPENSSL_LH_free()
84 for (i = 0; i < lh->num_nodes; i++) { in OPENSSL_LH_free()
85 n = lh->b[i]; in OPENSSL_LH_free()
92 OPENSSL_free(lh->b); in OPENSSL_LH_free()
93 OPENSSL_free(lh); in OPENSSL_LH_free()
96 void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data) in OPENSSL_LH_insert() argument
102 lh->error = 0; in OPENSSL_LH_insert()
103 if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh)) in OPENSSL_LH_insert()
106 rn = getrn(lh, data, &hash); in OPENSSL_LH_insert()
110 lh->error++; in OPENSSL_LH_insert()
118 lh->num_insert++; in OPENSSL_LH_insert()
119 lh->num_items++; in OPENSSL_LH_insert()
123 lh->num_replace++; in OPENSSL_LH_insert()
128 void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data) in OPENSSL_LH_delete() argument
134 lh->error = 0; in OPENSSL_LH_delete()
135 rn = getrn(lh, data, &hash); in OPENSSL_LH_delete()
138 lh->num_no_delete++; in OPENSSL_LH_delete()
145 lh->num_delete++; in OPENSSL_LH_delete()
148 lh->num_items--; in OPENSSL_LH_delete()
149 if ((lh->num_nodes > MIN_NODES) && in OPENSSL_LH_delete()
150 (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))) in OPENSSL_LH_delete()
151 contract(lh); in OPENSSL_LH_delete()
156 void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data) in OPENSSL_LH_retrieve() argument
162 tsan_store((TSAN_QUALIFIER int *)&lh->error, 0); in OPENSSL_LH_retrieve()
164 rn = getrn(lh, data, &hash); in OPENSSL_LH_retrieve()
167 tsan_counter(&lh->num_retrieve_miss); in OPENSSL_LH_retrieve()
171 tsan_counter(&lh->num_retrieve); in OPENSSL_LH_retrieve()
177 static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg, in doall_util_fn() argument
184 if (lh == NULL) in doall_util_fn()
191 for (i = lh->num_nodes - 1; i >= 0; i--) { in doall_util_fn()
192 a = lh->b[i]; in doall_util_fn()
204 void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func) in OPENSSL_LH_doall() argument
206 doall_util_fn(lh, 0, func, (OPENSSL_LH_DOALL_FUNCARG)0, NULL); in OPENSSL_LH_doall()
209 void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg) in OPENSSL_LH_doall_arg() argument
211 doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg); in OPENSSL_LH_doall_arg()
214 static int expand(OPENSSL_LHASH *lh) in expand() argument
220 nni = lh->num_alloc_nodes; in expand()
221 p = lh->p; in expand()
222 pmax = lh->pmax; in expand()
225 n = OPENSSL_realloc(lh->b, sizeof(OPENSSL_LH_NODE *) * j); in expand()
227 lh->error++; in expand()
230 lh->b = n; in expand()
232 lh->pmax = nni; in expand()
233 lh->num_alloc_nodes = j; in expand()
234 lh->num_expand_reallocs++; in expand()
235 lh->p = 0; in expand()
237 lh->p++; in expand()
240 lh->num_nodes++; in expand()
241 lh->num_expands++; in expand()
242 n1 = &(lh->b[p]); in expand()
243 n2 = &(lh->b[p + pmax]); in expand()
260 static void contract(OPENSSL_LHASH *lh) in contract() argument
264 np = lh->b[lh->p + lh->pmax - 1]; in contract()
265 lh->b[lh->p + lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */ in contract()
266 if (lh->p == 0) { in contract()
267 n = OPENSSL_realloc(lh->b, in contract()
268 (unsigned int)(sizeof(OPENSSL_LH_NODE *) * lh->pmax)); in contract()
271 lh->error++; in contract()
274 lh->num_contract_reallocs++; in contract()
275 lh->num_alloc_nodes /= 2; in contract()
276 lh->pmax /= 2; in contract()
277 lh->p = lh->pmax - 1; in contract()
278 lh->b = n; in contract()
280 lh->p--; in contract()
282 lh->num_nodes--; in contract()
283 lh->num_contracts++; in contract()
285 n1 = lh->b[(int)lh->p]; in contract()
287 lh->b[(int)lh->p] = np; in contract()
295 static OPENSSL_LH_NODE **getrn(OPENSSL_LHASH *lh, in getrn() argument
302 hash = (*(lh->hash)) (data); in getrn()
303 tsan_counter(&lh->num_hash_calls); in getrn()
306 nn = hash % lh->pmax; in getrn()
307 if (nn < lh->p) in getrn()
308 nn = hash % lh->num_alloc_nodes; in getrn()
310 cf = lh->comp; in getrn()
311 ret = &(lh->b[(int)nn]); in getrn()
313 tsan_counter(&lh->num_hash_comps); in getrn()
318 tsan_counter(&lh->num_comp_calls); in getrn()
377 unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh) in OPENSSL_LH_num_items() argument
379 return lh ? lh->num_items : 0; in OPENSSL_LH_num_items()
382 unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh) in OPENSSL_LH_get_down_load() argument
384 return lh->down_load; in OPENSSL_LH_get_down_load()
387 void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load) in OPENSSL_LH_set_down_load() argument
389 lh->down_load = down_load; in OPENSSL_LH_set_down_load()
392 int OPENSSL_LH_error(OPENSSL_LHASH *lh) in OPENSSL_LH_error() argument
394 return lh->error; in OPENSSL_LH_error()