/* * Simple hash table implementation. * * Nickolai Zeldovich * September 2001 */ #define HASHTAB_MAX_KEYLEN 8 #define HASHTAB_ENTRIES 256 struct hashtab_ent { const u_char key[HASHTAB_MAX_KEYLEN]; int keylen; int value; struct hashtab_ent *next; struct hashtab_ent *iter_next; }; struct hashtab { struct hashtab_ent *ent[HASHTAB_ENTRIES]; struct hashtab_ent *iter; int keycount; }; struct hashtab *hash_alloc(); void hash_free(struct hashtab *h); int hash_get(struct hashtab *h, const u_char *key_data, int key_len); void hash_put(struct hashtab *h, const u_char *key_data, int key_len, int value); int hash_get_keycount(struct hashtab *h); void *hash_get_iter(struct hashtab *h); void *hash_get_iter_next(void *opaque); const u_char *hash_get_iter_key(void *opaque); int hash_get_iter_key_len(void *opaque);