/[svn]/ircd-hybrid-7.2/src/hash.c
ViewVC logotype

Diff of /ircd-hybrid-7.2/src/hash.c

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

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

Legend:
Removed from v.896  
changed lines
  Added in v.982

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