00001 //based on http://en.literateprograms.org/Hash_table_%28C%29 00002 #include<stdlib.h> 00003 00004 typedef size_t hash_size; 00005 00006 struct hashnode_s { 00007 char *key; 00008 void *data; 00009 struct hashnode_s *next; 00010 }; 00011 00012 typedef struct hashtbl { 00013 hash_size size; 00014 struct hashnode_s **nodes; 00015 } HASHTBL; 00016 00017 00018 HASHTBL *hashtbl_create(hash_size size/*, hash_size (*hashfunc)(const char *)*/); 00019 void hashtbl_destroy(HASHTBL *hashtbl); 00020 int hashtbl_insert(HASHTBL *hashtbl, const char *key, void *data); 00021 int hashtbl_remove(HASHTBL *hashtbl, const char *key); 00022 void *hashtbl_get(HASHTBL *hashtbl, const char *key); 00023