]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/hash.c
Cleanups to 005 code, from ratbox (androsyn).
[irc/rqf/shadowircd.git] / src / hash.c
index f10c5ae5a707117077df33faa4de131eb17d121f..9ff4b1259a72f0619f2f972922d9fdaafc0a47be 100644 (file)
@@ -46,7 +46,6 @@ dlink_list *channelTable;
 dlink_list *idTable;
 dlink_list *resvTable;
 dlink_list *hostTable; 
-dlink_list *helpTable;
 
 /*
  * look in whowas.c for the missing ...[WW_MAX]; entry
@@ -97,7 +96,6 @@ init_hash(void)
        channelTable = MyMalloc(sizeof(dlink_list) * CH_MAX);
        hostTable = MyMalloc(sizeof(dlink_list) * HOST_MAX);
        resvTable = MyMalloc(sizeof(dlink_list) * R_MAX);
-       helpTable = MyMalloc(sizeof(dlink_list) * HELP_MAX);
 }
 
 #ifndef RICER_HASHING
@@ -111,7 +109,8 @@ fnv_hash_upper(const unsigned char *s, int bits)
                h ^= ToUpper(*s++);
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 
@@ -125,7 +124,8 @@ fnv_hash(const unsigned char *s, int bits)
                h ^= *s++;
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 
@@ -139,7 +139,8 @@ fnv_hash_len(const unsigned char *s, int bits, int len)
                h ^= *s++;
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 
@@ -153,7 +154,8 @@ fnv_hash_upper_len(const unsigned char *s, int bits, int len)
                h ^= ToUpper(*s++);
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 #endif
@@ -209,19 +211,6 @@ hash_resv(const char *name)
        return fnv_hash_upper_len((const unsigned char *) name, R_MAX_BITS, 30);
 }
 
-static unsigned int
-hash_help(const char *name)
-{
-       unsigned int h = 0;
-
-       while(*name)
-       {
-               h += (unsigned int) (ToLower(*name++) & 0xDF);
-       }
-
-       return (h % HELP_MAX);
-}
-
 /* add_to_id_hash()
  *
  * adds an entry to the id hash table
@@ -292,18 +281,6 @@ add_to_resv_hash(const char *name, struct ConfItem *aconf)
        dlinkAddAlloc(aconf, &resvTable[hashv]);
 }
 
-void
-add_to_help_hash(const char *name, struct cachefile *hptr)
-{
-       unsigned int hashv;
-
-       if(EmptyString(name) || hptr == NULL)
-               return;
-
-       hashv = hash_help(name);
-       dlinkAddAlloc(hptr, &helpTable[hashv]);
-}
-
 /* del_from_id_hash()
  *
  * removes an id from the id hash table
@@ -396,21 +373,6 @@ del_from_resv_hash(const char *name, struct ConfItem *aconf)
        dlinkFindDestroy(aconf, &resvTable[hashv]);
 }
 
-void
-clear_help_hash(void)
-{
-       dlink_node *ptr;
-       dlink_node *next_ptr;
-       int i;
-
-       HASH_WALK_SAFE(i, HELP_MAX, ptr, next_ptr, helpTable)
-       {
-               free_cachefile(ptr->data);
-               dlinkDestroy(ptr, &helpTable[i]);
-       }
-       HASH_WALK_END
-}
-
 /* find_id()
  *
  * finds a client entry from the id hash table
@@ -678,30 +640,6 @@ hash_find_resv(const char *name)
        return NULL;
 }
 
-struct cachefile *
-hash_find_help(const char *name, int flags)
-{
-       struct cachefile *hptr;
-       dlink_node *ptr;
-       unsigned int hashv;
-
-       if(EmptyString(name))
-               return NULL;
-
-       hashv = hash_help(name);
-
-       DLINK_FOREACH(ptr, helpTable[hashv].head)
-       {
-               hptr = ptr->data;
-
-               if((irccmp(name, hptr->name) == 0) &&
-                  (hptr->flags & flags))
-                       return hptr;
-       }
-
-       return NULL;
-}
-
 void
 clear_resv_hash(void)
 {