return;
}
+static uint64_t internal_ht_hash_fn(HT_KEY *key)
+{
+ return ossl_fnv1a_hash(key->keybuf, key->keysize);
+}
+
HT *ossl_ht_new(const HT_CONFIG *conf)
{
HT *new = OPENSSL_zalloc(sizeof(*new));
goto err;
if (new->config.ht_hash_fn == NULL)
- new->config.ht_hash_fn = ossl_fnv1a_hash;
+ new->config.ht_hash_fn = internal_ht_hash_fn;
return new;
* we have to take our lock here to prevent other changes
* to the bucket list
*/
- hash = h->config.ht_hash_fn(key->keybuf, key->keysize);
+ hash = h->config.ht_hash_fn(key);
for (i = 0;
(rc = ossl_ht_insert_locked(h, hash, newval, olddata)) == -1
uint64_t ehash;
int lockless_reads = h->config.lockless_reads;
- hash = h->config.ht_hash_fn(key->keybuf, key->keysize);
+ hash = h->config.ht_hash_fn(key);
md = ossl_rcu_deref(&h->md);
neigh_idx = neigh_idx_start = hash & md->neighborhood_mask;
if (h->config.lockless_reads)
return 0;
- hash = h->config.ht_hash_fn(key->keybuf, key->keysize);
+ hash = h->config.ht_hash_fn(key);
neigh_idx = hash & h->md->neighborhood_mask;
PREFETCH_NEIGHBORHOOD(h->md->neighborhoods[neigh_idx]);
typedef struct ht_config_st {
OSSL_LIB_CTX *ctx;
void (*ht_free_fn)(HT_VALUE *obj);
- uint64_t (*ht_hash_fn)(uint8_t *key, size_t keylen);
+ uint64_t (*ht_hash_fn)(HT_KEY *key);
size_t init_neighborhoods;
uint32_t collision_check;
uint32_t lockless_reads;
return 1;
}
-static uint64_t hashtable_hash(uint8_t *key, size_t keylen)
+static uint64_t hashtable_hash(HT_KEY *key)
{
- return (uint64_t)(*(uint32_t *)key);
+ return (uint64_t)(*(uint32_t *)key->keybuf);
}
static int test_int_hashtable(void)