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

Comparing ray/src/hd/holofile.c (file contents):
Revision 3.2 by gregl, Fri Oct 31 15:48:32 1997 UTC vs.
Revision 3.3 by gregl, Mon Nov 3 13:40:22 1997 UTC

# Line 142 | Line 142 | register HOLO  *hp;
142          }
143          if (!hp->dirty)                 /* check first */
144                  return(0);
145 +        errno = 0;
146          if (lseek(hp->fd, biglob(hp)->fo, 0) < 0)
147                  error(SYSTEM, "cannot seek on holodeck file");
148          n = nbeams(hp)*sizeof(BEAMI);
# Line 221 | Line 222 | int    nr;                     /* number of new rays desired */
222                  hp->bl[i]->tick = hdclock;      /* preempt swap */
223          if (hdcachesize > 0 && hdmemuse(0) >= hdcachesize)
224                  hdfreecache(PCTFREE, NULL);     /* free some space */
225 +        errno = 0;
226          if (hp->bl[i] == NULL) {                /* allocate (and load) */
227                  n = hp->bi[i].nrd + nr;
228                  if ((hp->bl[i] = (BEAM *)malloc(hdbsiz(n))) == NULL)
# Line 316 | Line 318 | register int   i;
318                          }
319                                          /* coalesce adjacent fragments */
320                          for (j = k = 0; k < f->nfrags; j++, k++) {
321 <                                if (j != k)
321 >                                if (k > j)
322                                          copystruct(f->fi+j, f->fi+k);
323 <                                while (k+1 < f->nfrags &&
324 <                                f->fi[k+1].fo + f->fi[k+1].nrd*sizeof(RAYVAL)
325 <                                                == f->fi[j].fo)
323 >                                while (k+1 < f->nfrags && f->fi[k+1].fo +
324 >                                                f->fi[k+1].nrd*sizeof(RAYVAL)
325 >                                                        == f->fi[j].fo) {
326                                          f->fi[j].fo -=
327                                                  f->fi[++k].nrd*sizeof(RAYVAL);
328 +                                        f->fi[j].nrd += f->fi[k].nrd;
329 +                                }
330                          }
331                          f->nfrags = j;
332                  }
333                  k = -1;                 /* find closest-sized fragment */
334                  for (j = f->nfrags; j-- > 0; )
335                          if (f->fi[j].nrd >= nrays &&
336 <                                        (k < 0 || f->fi[j].nrd < f->fi[k].nrd)
337 <                                        && f->fi[k=j].nrd == nrays)
338 <                                break;
336 >                                        (k < 0 || f->fi[j].nrd < f->fi[k].nrd))
337 >                                if (f->fi[k=j].nrd == nrays)
338 >                                        break;
339                  if (k < 0) {            /* no fragment -- extend file */
340                          hp->bi[i].fo = f->flen;
341                          f->flen += nrays*sizeof(RAYVAL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines