ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/hash.c
(Generate patch)

Comparing ircd-hybrid-7.2/src/hash.c (file contents):
Revision 981 by michael, Sat Nov 3 08:54:09 2007 UTC vs.
Revision 982 by michael, Thu Aug 13 22:15:08 2009 UTC

# Line 34 | Line 34
34   #include "modules.h"
35   #include "hash.h"
36   #include "resv.h"
37 + #include "rng_mt.h"
38   #include "userhost.h"
39   #include "irc_string.h"
40   #include "ircd.h"
# Line 48 | Line 49 | static BlockHeap *userhost_heap = NULL;
49   static BlockHeap *namehost_heap = NULL;
50   static struct UserHost *find_or_add_userhost(const char *);
51  
52 < static unsigned int ircd_random_key = 0;
52 > static unsigned int hashf_xor_key = 0;
53  
54   /* The actual hash tables, They MUST be of the same HASHSIZE, variable
55   * size tables could be supported but the rehash routine should also
# Line 81 | Line 82 | init_hash(void)
82    userhost_heap = BlockHeapCreate("userhost", sizeof(struct UserHost), CLIENT_HEAP_SIZE);
83    namehost_heap = BlockHeapCreate("namehost", sizeof(struct NameHost), CLIENT_HEAP_SIZE);
84  
85 <  ircd_random_key = rand() % 256;  /* better than nothing --adx */
85 >  hashf_xor_key = genrand_int32() % 256;  /* better than nothing --adx */
86  
87    /* Clear the hash tables first */
88    for (i = 0; i < HASHSIZE; ++i)
# Line 113 | Line 114 | strhash(const char *name)
114    {
115      hval += (hval << 1) + (hval <<  4) + (hval << 7) +
116              (hval << 8) + (hval << 24);
117 <    hval ^= (ToLower(*p) ^ ircd_random_key);
117 >    hval ^= (ToLower(*p) ^ hashf_xor_key);
118    }
119  
120 <  return (hval >> FNV1_32_BITS) ^ (hval & ((1 << FNV1_32_BITS) -1));
120 >  return (hval >> FNV1_32_BITS) ^ (hval & ((1 << FNV1_32_BITS) - 1));
121   }
122  
123   /************************** Externally visible functions ********************/

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)