From 9b8d802ca89027de46ee45fbc9adf978a16e7927 Mon Sep 17 00:00:00 2001 From: Epoch Qwert Date: Sun, 7 Sep 2014 02:53:24 -0500 Subject: small fix with libhashtable's header --- libhashtable/example.c | 5 ++--- libhashtable/hashtable.h | 23 +++++++++++++++++++++++ libhashtable/libhashtable.h | 23 ----------------------- 3 files changed, 25 insertions(+), 26 deletions(-) create mode 100644 libhashtable/hashtable.h delete mode 100644 libhashtable/libhashtable.h diff --git a/libhashtable/example.c b/libhashtable/example.c index 614e440..bc42a67 100644 --- a/libhashtable/example.c +++ b/libhashtable/example.c @@ -1,5 +1,5 @@ #include -#include "libhashtable.h" +#include "hashtable.h" extern char **environ; @@ -8,14 +8,13 @@ int main(int argc,char *argv[]) { int i; char *name; char *value; - inittable(&ht); + inittable(&ht,65535); for(i=0;environ[i];i++) { name=strdup(environ[i]); if((value=strchr(name,'=') )){ *value=0; value++; } - //printf("'%s' = '%s'\n",name,value); ht_setkey(&ht,name,value); free(name); } diff --git a/libhashtable/hashtable.h b/libhashtable/hashtable.h new file mode 100644 index 0000000..820d230 --- /dev/null +++ b/libhashtable/hashtable.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 tsize); +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); diff --git a/libhashtable/libhashtable.h b/libhashtable/libhashtable.h deleted file mode 100644 index 7899124..0000000 --- a/libhashtable/libhashtable.h +++ /dev/null @@ -1,23 +0,0 @@ -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