| 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" |
| 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 |
| 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) |
| 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 ********************/ |