16 |
|
|
17 |
|
#define MAXORDER (8*sizeof(unsigned short)) |
18 |
|
|
19 |
< |
unsigned short *urperm = NULL; /* urand() permutation */ |
20 |
< |
int urmask; /* bits used in permutation */ |
19 |
> |
static unsigned short empty_tab = 0; |
20 |
|
|
21 |
+ |
unsigned short *urperm = &empty_tab; /* urand() permutation */ |
22 |
+ |
int urmask = 0; /* bits used in permutation */ |
23 |
+ |
|
24 |
|
int |
25 |
|
initurand(size) /* initialize urand() for size entries */ |
26 |
|
int size; |
28 |
|
int order, n; |
29 |
|
register int i, offset; |
30 |
|
|
31 |
< |
if (urperm != NULL) |
31 |
> |
if ((urperm != NULL) & (urperm != &empty_tab)) |
32 |
|
free((void *)urperm); |
33 |
|
if (--size <= 0) { |
34 |
< |
urperm = NULL; |
34 |
> |
empty_tab = 0; |
35 |
> |
urperm = &empty_tab; |
36 |
|
urmask = 0; |
37 |
|
return(0); |
38 |
|
} |
64 |
|
register int *d; |
65 |
|
register int n; |
66 |
|
{ |
67 |
< |
static int tab[8] = {13623,353,1637,5831,2314,3887,5832,8737}; |
67 |
> |
static int tab[8] = {103699,96289,73771,65203,81119,87037,92051,98899}; |
68 |
|
register int hval; |
69 |
|
|
70 |
|
hval = 0; |
71 |
|
while (n-- > 0) |
72 |
< |
hval += *d++ * tab[n&7]; |
73 |
< |
return(hval); |
72 |
> |
hval ^= *d++ * tab[n&7]; |
73 |
> |
return(hval & 0x7fffffff); |
74 |
|
} |