-/* $OpenBSD: lhash.c,v 1.26 2024/06/22 16:38:31 jsing Exp $ */
+/* $OpenBSD: lhash.c,v 1.27 2024/06/30 14:13:08 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
unsigned long hash, nni;
lh->num_nodes++;
- lh->num_expands++;
p = (int)lh->p++;
n1 = &(lh->b[p]);
n2 = &(lh->b[p + (int)lh->pmax]);
hash = np->hash;
#else
hash = lh->hash(np->data);
- lh->num_hash_calls++;
#endif
if ((hash % nni) != p) { /* move it */
*n1 = (*n1)->next;
n[i] = NULL; /* 02/03/92 eay */
lh->pmax = lh->num_alloc_nodes;
lh->num_alloc_nodes = j;
- lh->num_expand_reallocs++;
lh->p = 0;
lh->b = n;
}
lh->error++;
return;
}
- lh->num_contract_reallocs++;
lh->num_alloc_nodes /= 2;
lh->pmax /= 2;
lh->p = lh->pmax - 1;
lh->p--;
lh->num_nodes--;
- lh->num_contracts++;
n1 = lh->b[(int)lh->p];
if (n1 == NULL)
LHASH_COMP_FN_TYPE cf;
hash = (*(lh->hash))(data);
- lh->num_hash_calls++;
*rhash = hash;
nn = hash % lh->pmax;
ret = &(lh->b[(int)nn]);
for (n1 = *ret; n1 != NULL; n1 = n1->next) {
#ifndef OPENSSL_NO_HASH_COMP
- lh->num_hash_comps++;
if (n1->hash != hash) {
ret = &(n1->next);
continue;
}
#endif
- lh->num_comp_calls++;
if (cf(n1->data, data) == 0)
break;
ret = &(n1->next);
#endif
*rn = nn;
ret = NULL;
- lh->num_insert++;
lh->num_items++;
}
else /* replace same key */
{
ret = (*rn)->data;
(*rn)->data = data;
- lh->num_replace++;
}
return (ret);
}
rn = getrn(lh, data, &hash);
if (*rn == NULL) {
- lh->num_no_delete++;
return (NULL);
} else {
nn= *rn;
*rn = nn->next;
ret = nn->data;
free(nn);
- lh->num_delete++;
}
lh->num_items--;
rn = getrn(lh, data, &hash);
if (*rn == NULL) {
- lh->num_retrieve_miss++;
return (NULL);
} else {
ret = (*rn)->data;
- lh->num_retrieve++;
}
return (ret);
}
-/* $OpenBSD: lhash_local.h,v 1.1 2024/03/02 11:11:11 tb Exp $ */
+/* $OpenBSD: lhash_local.h,v 1.2 2024/06/30 14:13:08 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
unsigned long down_load; /* load times 256 */
unsigned long num_items;
- unsigned long num_expands;
- unsigned long num_expand_reallocs;
- unsigned long num_contracts;
- unsigned long num_contract_reallocs;
- unsigned long num_hash_calls;
- unsigned long num_comp_calls;
- unsigned long num_insert;
- unsigned long num_replace;
- unsigned long num_delete;
- unsigned long num_no_delete;
- unsigned long num_retrieve;
- unsigned long num_retrieve_miss;
- unsigned long num_hash_comps;
-
int error;
} /* _LHASH */;