2 * hash.h - hashing routines mainly used for caching key details.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2000-2002 Project Purple
12 #include "keystructs.h"
16 #define HASHMASK 0x3FF
19 * inithash - Initialize the hash ready for use.
21 * This function prepares the hash ready for use. It should be called
22 * before any of the functions below are used.
27 * destroyhash - Clean up the hash after use.
29 * This function destroys the hash after use, freeing any memory that was
30 * used during its lifetime.
32 void destroyhash(void);
35 * addtohash - Adds a key to the hash.
36 * @key: The key to add.
38 * Takes a key and stores it in the hash.
40 void addtohash(struct stats_key *key);
43 * createandaddtohash - Creates a key and adds it to the hash.
44 * @keyid: The key to create and add.
46 * Takes a key, checks if it exists in the hash and if not creates it
47 * and adds it to the hash. Returns the key from the hash whether it
48 * already existed or we just created it.
50 struct stats_key *createandaddtohash(uint64_t keyid);
53 * findinhash - Finds a key in the hash.
54 * @keyid: The key we want.
56 * Finds a key in the hash and returns it.
58 struct stats_key *findinhash(uint64_t keyid);
61 * hashelements - Returns the size of the hash
63 * Returns the number of elements that have been loaded into the hash.
65 unsigned long hashelements(void);
68 * gethashtableentry - Returns an entry from the hash table.
69 * @entry: The entry to return. 0 <= entry < HASHSIZE must hold.
71 * Gets a particular entry from the hash. Useful for doing something over
72 * all entries in the hash.
74 struct ll *gethashtableentry(int entry);
76 #endif /* __HASH_H__ */