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

Comparing ray/src/cal/cnt.c (file contents):
Revision 1.5 by greg, Wed Apr 20 20:56:01 2022 UTC vs.
Revision 1.8 by greg, Fri Apr 22 15:52:50 2022 UTC

# Line 161 | Line 161 | incr_counter(uby8 *ctrp, int n)
161   {
162          n = tree_br[n].cntr_siz;
163  
164 <        while (n-- > 0)                 /* LSB first */
165 <                if (++(*ctrp++))
166 <                        break;
164 >        while (! ++(*ctrp++))           /* LSB first */
165 >                if (--n <= 0) {
166 >                        fputs("Shuffle occupancy overflow!\n", stderr);
167 >                        exit(1);        /* means we sized something wrong */
168 >                }
169   }
170  
171  
# Line 213 | Line 215 | big_shuffle(long *n, long alen)
215          tree_root = tree_alloc(alen);
216  
217          while (alen > 0)                /* allocate and print random array entries */
218 <                print_shuf(n, eat_nth_leaf(tree_root, random() % alen--));
218 >                print_shuf(n, eat_nth_leaf(tree_root, irandom(alen--)));
219  
220          free(tree_root);                /* all done */
221   }
# Line 251 | Line 253 | shuffle(long *n)
253                  myshuf[i] = i;
254                                  /* perform Fisher-Yates shuffle */
255          for (i = 0; i < alen-1; i++) {
256 <                int     ix = random()%(alen-i) + i;
256 >                int     ix = irandom(alen-i) + i;
257                  int     ndx = myshuf[i];
258                  myshuf[i] = myshuf[ix];
259                  myshuf[ix] = ndx;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines