00001 /*************************************************************************** 00002 * DESCRIPTION: 00003 * A simple hash table implementation for strings, contributed by John Stone, 00004 * derived from his ray tracer code. 00005 ***************************************************************************/ 00006 00007 #ifdef __cplusplus 00008 extern "C" { 00009 #endif 00010 00011 typedef struct hash_t { 00012 struct hash_node_t **bucket; /* array of hash nodes */ 00013 int size; /* size of the array */ 00014 int entries; /* number of entries in table */ 00015 int downshift; /* shift cound, used in hash function */ 00016 int mask; /* used to select bits for hashing */ 00017 } hash_t; 00018 00019 #define HASH_FAIL -1 00020 00021 void hash_init(hash_t *, int); 00022 void* hash_lookup (const hash_t *, const char *); 00023 void* hash_insert (hash_t *, const char *, void *); 00024 void* hash_delete (hash_t *, const char *); 00025 void hash_destroy(hash_t *, void (*free_data)(void *)); 00026 char *hash_stats (hash_t *); 00027 00028 #ifdef __cplusplus 00029 } 00030 #endif 00031
1.2.18