From 3efd96ff79f4f5669c3422a1f592f09176c77121 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 15 Aug 2009 18:07:02 +0200 Subject: Added a hash table to keep track of words. Moved the sdbm hash function into sdbm.c. Init and free users and words inside the channel loop. Increased the size of the user hash table to 1000. --- user.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'user.c') diff --git a/user.c b/user.c index 064007b..a9e2927 100644 --- a/user.c +++ b/user.c @@ -2,6 +2,7 @@ #include #include "user.h" +#include "sdbm.h" struct user_t *users; @@ -10,15 +11,6 @@ void user_init() { memset(users, 0, sizeof(struct user_t) * USERS_MAX); } -static unsigned long sdbm(char *str) { - unsigned long hash = 0; - int c; - while(c = *str++) { - hash = c + (hash << 6) + (hash << 16) - hash; - } - return hash; -} - struct user_t *user_get(char *nick) { unsigned long hash = sdbm(nick); int index = hash % USERS_MAX; -- cgit v1.2.3