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

Comparing ray/src/hd/rholo3.c (file contents):
Revision 3.32 by gwlarson, Thu Mar 4 15:44:10 1999 UTC vs.
Revision 3.36 by greg, Tue May 13 17:58:33 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines for tracking beam compuatations
6   */
7  
8   #include "rholo.h"
9   #include "view.h"
13 #include <sys/types.h>
10  
11   #ifndef NFRAG2CHUNK
12   #define NFRAG2CHUNK     4096    /* number of fragments to start chunking */
# Line 92 | Line 88 | register HDBEAMI       *hb;
88          if (b->nrm > n) {               /* (re)allocate packet holder */
89                  n = b->nrm;
90                  if (p == NULL) p = (PACKHEAD *)malloc(packsiz(n));
91 <                else p = (PACKHEAD *)realloc((char *)p, packsiz(n));
91 >                else p = (PACKHEAD *)realloc((void *)p, packsiz(n));
92                  CHECK(p==NULL, SYSTEM, "out of memory in dispbeam");
93          }
94                                          /* assign packet fields */
95 <        bcopy((char *)hdbray(b), (char *)packra(p), b->nrm*sizeof(RAYVAL));
95 >        bcopy((void *)hdbray(b), (void *)packra(p), b->nrm*sizeof(RAYVAL));
96          p->nr = p->nc = b->nrm;
97          for (p->hd = 0; hdlist[p->hd] != hb->h; p->hd++)
98                  if (hdlist[p->hd] == NULL)
# Line 104 | Line 100 | register HDBEAMI       *hb;
100          p->bi = hb->b;
101          disp_packet(p);                 /* display it */
102          if (n >= 1024) {                /* free ridiculous packets */
103 <                free((char *)p);
103 >                free((void *)p);
104                  p = NULL; n = 0;
105          }
106   }
# Line 122 | Line 118 | int    nents;
118                                          /* search for common members */
119          for (csm = clist+nents; csm-- > clist; )
120                  csm->nc = -1;
121 <        qsort((char *)clist, nents, sizeof(PACKHEAD), beamidcmp);
121 >        qsort((void *)clist, nents, sizeof(PACKHEAD), beamidcmp);
122          for (i = 0; i < complen; i++) {
123 <                csm = (PACKHEAD *)bsearch((char *)(complist+i), (char *)clist,
123 >                csm = (PACKHEAD *)bsearch((void *)(complist+i), (void *)clist,
124                                  nents, sizeof(PACKHEAD), beamidcmp);
125                  if (csm == NULL)
126                          continue;
# Line 163 | Line 159 | int    nents;
159          case BS_NEW:                    /* new computation set */
160                  listpos = 0; lastin = -1;
161                  if (complen)            /* free old list */
162 <                        free((char *)complist);
162 >                        free((void *)complist);
163                  complist = NULL;
164                  if (!(complen = nents))
165                          return;
166                  complist = (PACKHEAD *)malloc(nents*sizeof(PACKHEAD));
167                  if (complist == NULL)
168                          goto memerr;
169 <                bcopy((char *)clist, (char *)complist, nents*sizeof(PACKHEAD));
169 >                bcopy((void *)clist, (void *)complist, nents*sizeof(PACKHEAD));
170                  break;
171          case BS_ADD:                    /* add to computation set */
172          case BS_MAX:                    /* maximum of quantities */
# Line 178 | Line 174 | int    nents;
174                  if (nents <= 0)
175                          return;
176                  sortcomplist();         /* sort updated list & new entries */
177 <                qsort((char *)clist, nents, sizeof(PACKHEAD), beamcmp);
177 >                qsort((void *)clist, nents, sizeof(PACKHEAD), beamcmp);
178                                          /* what can't we satisfy? */
179                  for (i = nents, csm = clist; i-- && csm->nr > csm->nc; csm++)
180                          ;
# Line 197 | Line 193 | int    nents;
193                                                  /* merge lists */
194                          mergeclists(newlist, clist, n, complist, complen);
195                          if (complen)
196 <                                free((char *)complist);
196 >                                free((void *)complist);
197                          complist = newlist;
198                          complen += n;
199                  }
# Line 218 | Line 214 | int    nents;
214                  hbarr[i].b = clist[i].bi;
215          }
216          hdloadbeams(hbarr, nents, dispbeam);
217 <        free((char *)hbarr);
217 >        free((void *)hbarr);
218          if (hdfragflags&FF_READ) {
219                  listpos = 0;
220                  lastin = -1;            /* need to re-sort list */
# Line 322 | Line 318 | FILE   *fp;
318                  normaspect(viewaspect(&curview), &pa, &xr, &yr);
319                  viewbeams(&curview, xr, yr, &blist);
320                  bundle_set(BS_MAX, blist.bl, blist.nb);
321 <                free((char *)blist.bl);
321 >                free((void *)blist.bl);
322          }
323   }
324  
# Line 332 | Line 328 | init_global()                  /* initialize global ray computation *
328          register int    k;
329                                          /* free old list and empty queue */
330          if (complen > 0) {
331 <                free((char *)complist);
331 >                free((void *)complist);
332                  done_packets(flush_queue());
333          }
334                                          /* reseed random number generator */
# Line 391 | Line 387 | sortcomplist()                 /* fix our list order */
387   #endif
388                  }
389          if (lastin < 0 || listpos*4 >= complen*3)
390 <                qsort((char *)complist, complen, sizeof(PACKHEAD), beamcmp);
390 >                qsort((void *)complist, complen, sizeof(PACKHEAD), beamcmp);
391          else if (listpos) {     /* else sort and merge sublist */
392                  list2 = (PACKHEAD *)malloc(listpos*sizeof(PACKHEAD));
393                  CHECK(list2==NULL, SYSTEM, "out of memory in sortcomplist");
394 <                bcopy((char *)complist,(char *)list2,listpos*sizeof(PACKHEAD));
395 <                qsort((char *)list2, listpos, sizeof(PACKHEAD), beamcmp);
394 >                bcopy((void *)complist,(void *)list2,listpos*sizeof(PACKHEAD));
395 >                qsort((void *)list2, listpos, sizeof(PACKHEAD), beamcmp);
396                  mergeclists(complist, list2, listpos,
397                                  complist+listpos, complen-listpos);
398 <                free((char *)list2);
398 >                free((void *)list2);
399          }
400                                          /* drop satisfied requests */
401          for (i = complen; i-- && complist[i].nr <= complist[i].nc; )
402                  ;
403          if (i < 0) {
404 <                free((char *)complist);
404 >                free((void *)complist);
405                  complist = NULL;
406                  complen = 0;
407          } else if (i < complen-1) {
408 <                list2 = (PACKHEAD *)realloc((char *)complist,
408 >                list2 = (PACKHEAD *)realloc((void *)complist,
409                                  (i+1)*sizeof(PACKHEAD));
410                  if (list2 != NULL)
411                          complist = list2;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines