From f41ec6d42942f994f762486a9ab525ed8c5506e5 Mon Sep 17 00:00:00 2001 From: Epoch Qwert Date: Sun, 7 Sep 2014 02:37:46 -0500 Subject: took the hashtable stuff out of segfault and put it into a library. good idea? dunno. --- libhashtable/libhashtable.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 libhashtable/libhashtable.h (limited to 'libhashtable/libhashtable.h') diff --git a/libhashtable/libhashtable.h b/libhashtable/libhashtable.h new file mode 100644 index 0000000..7899124 --- /dev/null +++ b/libhashtable/libhashtable.h @@ -0,0 +1,23 @@ +struct entry {//linked list node. + char *original; + char *target; + struct entry *prev;// doubly linked list. why? + struct entry *next; +}; + +struct hitem {//dunno why I don't just have this as a linked list. + struct entry *ll; +}; + +struct hashtable { + int kl;//number of keys in the table + struct hitem **bucket; + int *keys; +}; +unsigned short hash(char *v);//maybe use a seeded rand()? :) Thanks FreeArtMan +void inittable(struct hashtable *ht); +int ht_setkey(struct hashtable *ht,char *key,char *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); +char *ht_getvalue(struct hashtable *ht,char *msg); -- cgit v1.2.3