33#define HASHTABLE_LOADFACTOR_NUM 7
34#define HASHTABLE_LOADFACTOR_DEN 10
39 unsigned size2, bits2;
42 size = 1 + size * HASHTABLE_LOADFACTOR_DEN / HASHTABLE_LOADFACTOR_NUM;
44 for (size2 = 2, bits2 = 1; (int)size2 < size; size2 <<= 1, bits2++) ;
45 if (!(t = calloc(1,
sizeof(
hashtable_t)+ size2 *
sizeof(
unsigned))))
47 if (!(t->
etable = calloc(size2,
sizeof(
void *)))) {
54#ifndef HASHTABLE_NBLOOM
55 if (!(t->
kbloom = calloc((size2 + 7) / 8,
sizeof(
unsigned char)))) {
59 t->
bshift = (unsigned)
sizeof(
unsigned) * 8 - bits2;
62#ifndef HASHTABLE_NSTATS
72#ifndef HASHTABLE_NBLOOM
A generic open addressing hashtable.
long find_count
The count of finds tried.
long match_count
The count of matches found.
int count
Number of entries in hashtable.
unsigned char * kbloom
Bloom filter of hash keys with k=1.
long entrycmp_count
The count of entry compares done.
int size
Size of allocated hashtable.
unsigned tmask
Mask to get the hashtable index.
void ** etable
Table of pointers to entries.
long hashcmp_count
The count of hash compares done.
unsigned bshift
Shift to get the bloomfilter index.