From 5fc8d2a2fbbe55fb3f92c4edd216f9e96d21a288 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Tue, 31 Mar 2015 12:54:01 -0500 Subject: init commit after splitting from segfault --- hashtable.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 hashtable.h (limited to 'hashtable.h') diff --git a/hashtable.h b/hashtable.h new file mode 100644 index 0000000..a58a392 --- /dev/null +++ b/hashtable.h @@ -0,0 +1,27 @@ +struct entry {//linked list node. + char *original; + void *target; + struct entry *prev;// doubly linked list. why? + struct entry *next; +}; + +struct hitem { + struct entry *ll; +}; + +struct hashtable { + int kl;//number of keys in the table + struct hitem **bucket; + int *keys; +}; +unsigned short hash(char *key);//maybe use a seeded rand()? :) Thanks FreeArtMan +void inittable(struct hashtable *ht,int tsize); +void ll_delete(struct entry *ll); +void ll_destroy(struct entry *ll); +void ht_destroy(struct hashtable *ht); +void ht_freevalues(struct hashtable *ht); +int ht_setkey(struct hashtable *ht,char *key,void *value); +struct entry *ll_getentry(struct entry *start,char *msg); +struct entry *ht_getentry(struct hashtable *ht,char *key); +struct entry *ht_getnode(struct hashtable *ht,char *msg); +void *ht_getvalue(struct hashtable *ht,char *msg); -- cgit v1.2.3