/[svn]/ircd-hybrid/branches/8.2.x/src/hash.c
ViewVC logotype

Diff of /ircd-hybrid/branches/8.2.x/src/hash.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9086 by michael, Sun Oct 13 09:58:37 2019 UTC revision 9087 by michael, Sun Oct 27 21:13:38 2019 UTC
# Line 41  Line 41 
41  #include "dbuf.h"  #include "dbuf.h"
42    
43    
 static unsigned int hashf_xor_key;  
   
44  /* The actual hash tables, They MUST be of the same HASHSIZE, variable  /* The actual hash tables, They MUST be of the same HASHSIZE, variable
45   * size tables could be supported but the rehash routine should also   * size tables could be supported but the rehash routine should also
46   * rebuild the transformation maps, I kept the tables of equal size   * rebuild the transformation maps, I kept the tables of equal size
# Line 53  static struct Client *clientTable[HASHSI Line 51  static struct Client *clientTable[HASHSI
51  static struct Channel *channelTable[HASHSIZE];  static struct Channel *channelTable[HASHSIZE];
52    
53    
 /* hash_init()  
  *  
  * inputs       - NONE  
  * output       - NONE  
  * side effects - Initialize the maps used by hash  
  *                functions and clear the tables  
  */  
 void  
 hash_init(void)  
 {  
   do  
     hashf_xor_key = genrand_int32() % 256;  /* better than nothing --adx */  
   while (!hashf_xor_key);  
 }  
   
54  /*  /*
55   * New hash function based on the Fowler/Noll/Vo (FNV) algorithm from   * New hash function based on the Fowler/Noll/Vo (FNV) algorithm from
56   * http://www.isthe.com/chongo/tech/comp/fnv/   * http://www.isthe.com/chongo/tech/comp/fnv/
# Line 78  hash_init(void) Line 61  hash_init(void)
61  unsigned int  unsigned int
62  strhash(const char *name)  strhash(const char *name)
63  {  {
64      static unsigned int hashf_xor_key = 0;
65    const unsigned char *p = (const unsigned char *)name;    const unsigned char *p = (const unsigned char *)name;
66    unsigned int hval = FNV1_32_INIT;    unsigned int hval = FNV1_32_INIT;
67    
68    if (EmptyString(p))    if (EmptyString(p))
69      return 0;      return 0;
70    
71      if (hashf_xor_key == 0)
72        do
73          hashf_xor_key = genrand_int32() % 256;  /* better than nothing --adx */
74        while (hashf_xor_key == 0);
75    
76    for (; *p; ++p)    for (; *p; ++p)
77    {    {
78      hval += (hval << 1) + (hval << 4) +      hval += (hval << 1) + (hval << 4) +

Legend:
Removed from v.9086  
changed lines
  Added in v.9087

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28