--- ray/src/common/urand.c 1991/06/07 10:50:14 1.5 +++ ray/src/common/urand.c 1998/01/05 16:47:37 2.4 @@ -1,7 +1,7 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1998 Silicon Graphics, Inc. */ #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static char SCCSid[] = "$SunId$ SGI"; #endif /* @@ -12,24 +12,29 @@ static char SCCSid[] = "$SunId$ LBL"; #define NULL 0 +#define MAXORDER (8*sizeof(unsigned short)) + extern char *malloc(); -short *urperm; /* urand() permutation */ +unsigned short *urperm = NULL; /* urand() permutation */ int urmask; /* bits used in permutation */ +int initurand(size) /* initialize urand() for size entries */ int size; { int order, n; register int i, offset; + if (urperm != NULL) + free((char *)urperm); size--; for (i = 1; size >>= 1; i++) ; - order = i; + order = i>MAXORDER ? MAXORDER : i; urmask = (1<