]> git.ipfire.org Git - thirdparty/squid.git/blame - include/hash.h
The rearrangement of store/file numbers broke the on-disk STORE_META_STD
[thirdparty/squid.git] / include / hash.h
CommitLineData
0e2cd867 1/*
186477c1 2 * $Id: hash.h,v 1.4 2000/10/31 23:48:08 wessels Exp $
0e2cd867 3 */
4
f52a7d75 5typedef void HASHFREE(void *);
6typedef int HASHCMP(const void *, const void *);
7typedef unsigned int HASHHASH(const void *, unsigned int);
8typedef struct _hash_link hash_link;
9typedef struct _hash_table hash_table;
10
11struct _hash_link {
186477c1 12 void *key;
f52a7d75 13 hash_link *next;
14};
15
16struct _hash_table {
17 hash_link **buckets;
18 HASHCMP *cmp;
19 HASHHASH *hash;
20 unsigned int size;
21 unsigned int current_slot;
22 hash_link *next;
23 int count;
24};
25
26extern hash_table *hash_create(HASHCMP *, int, HASHHASH *);
27extern void hash_join(hash_table *, hash_link *);
28extern void hash_remove_link(hash_table *, hash_link *);
29extern int hashPrime(int n);
30extern void *hash_lookup(hash_table *, const void *);
31extern void hash_first(hash_table *);
32extern void *hash_next(hash_table *);
2c4f7ab2 33extern void hash_last(hash_table *);
f52a7d75 34extern hash_link *hash_get_bucket(hash_table *, unsigned int);
35extern void hashFreeMemory(hash_table *);
36extern void hashFreeItems(hash_table *, HASHFREE *);
37extern HASHHASH hash_string;
38extern HASHHASH hash4;
186477c1 39extern const char *hashKeyStr(hash_link *);
f52a7d75 40
41/*
42 * Here are some good prime number choices. It's important not to
43 * choose a prime number that is too close to exact powers of 2.
44 *
45 * HASH_SIZE 103 // prime number < 128
46 * HASH_SIZE 229 // prime number < 256
47 * HASH_SIZE 467 // prime number < 512
48 * HASH_SIZE 977 // prime number < 1024
49 * HASH_SIZE 1979 // prime number < 2048
50 * HASH_SIZE 4019 // prime number < 4096
51 * HASH_SIZE 6037 // prime number < 6144
52 * HASH_SIZE 7951 // prime number < 8192
53 * HASH_SIZE 12149 // prime number < 12288
54 * HASH_SIZE 16231 // prime number < 16384
55 * HASH_SIZE 33493 // prime number < 32768
56 * HASH_SIZE 65357 // prime number < 65536
57 */
186477c1 58#define DEFAULT_HASH_SIZE 7951 /* prime number < 8192 */