ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/urand.c
(Generate patch)

Comparing ray/src/common/urand.c (file contents):
Revision 1.3 by greg, Tue May 21 11:01:00 1991 UTC vs.
Revision 2.4 by gregl, Mon Jan 5 16:47:37 1998 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1998 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4 < static char SCCSid[] = "$SunId$ LBL";
4 > static char SCCSid[] = "$SunId$ SGI";
5   #endif
6  
7   /*
8 < * Uncorrelated (anticorrelated) random function
8 > * Anticorrelated random function due to Christophe Schlick
9   */
10  
11   #include  "random.h"
12  
13   #define  NULL           0
14  
15 + #define  MAXORDER       (8*sizeof(unsigned short))
16 +
17   extern char  *malloc();
18  
19 < short  *urperm;         /* urand() permutation */
19 > unsigned short  *urperm = NULL; /* urand() permutation */
20   int  urmask;            /* bits used in permutation */
21  
22  
23 + int
24   initurand(size)         /* initialize urand() for size entries */
25   int  size;
26   {
27          int  order, n;
28          register int  i, offset;
29  
30 +        if (urperm != NULL)
31 +                free((char *)urperm);
32          size--;
33          for (i = 1; size >>= 1; i++)
34                  ;
35 <        order = i;
35 >        order = i>MAXORDER ? MAXORDER : i;
36          urmask = (1<<i) - 1;
37 <        urperm = (short *)malloc((urmask+1)*sizeof(short));
37 >        urperm = (unsigned short *)malloc((urmask+1)*sizeof(unsigned short));
38          if (urperm == NULL) {
39                  eputs("out of memory in initurand\n");
40                  quit(1);
# Line 44 | Line 49 | int  size;
49                          else
50                                  urperm[i+offset]++;
51                  }
52 +        return(1<<order);
53   }
54  
55  
# Line 53 | Line 59 | register int  *d;
59   register int  n;
60   {
61          static int  tab[8] = {13623,353,1637,5831,2314,3887,5832,8737};
62 <        register unsigned  hval;
62 >        register int  hval;
63  
64          hval = 0;
65          while (n-- > 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines