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.32 by gwlarson, Thu Jan 7 22:04:49 1999 UTC vs.
Revision 3.35 by gwlarson, Mon Jan 25 09:58:41 1999 UTC

# Line 13 | Line 13 | static char SCCSid[] = "$SunId$ SGI";
13   #include "holo.h"
14  
15   #ifndef CACHESIZE
16 < #define CACHESIZE       16      /* default cache size (Mbytes, 0==inf) */
16 > #ifdef BIGMEM
17 > #define CACHESIZE       32      /* default cache size (Mbytes, 0==inf) */
18 > #else
19 > #define CACHESIZE       12
20   #endif
21 + #endif
22   #ifndef FREEBEAMS
23   #define FREEBEAMS       1500    /* maximum beams to free at a time */
24   #endif
# Line 483 | Line 487 | int    (*bf)();                /* callback function (optional) */
487   }
488  
489  
490 + int
491   hdfreefrag(hp, i)                       /* free a file fragment */
492   HOLO    *hp;
493   int     i;
# Line 492 | Line 497 | int    i;
497          register int    j, k;
498  
499          if (bi->nrd <= 0)
500 <                return;
500 >                return(0);
501          DCHECK(hp->fd < 0 | hp->fd >= nhdfragls || !hdfragl[hp->fd].nlinks,
502                          CONSISTENCY, "bad file descriptor in hdfreefrag");
503          f = &hdfragl[hp->fd];
# Line 512 | Line 517 | int    i;
517          if (j >= MAXFRAGB*FRAGBLK) {
518                  f->nfrags = j--;        /* stop list growth */
519                  if (bi->nrd <= f->fi[j].nrd)
520 <                        return;         /* new one no better than discard */
520 >                        return(0);      /* new one no better than discard */
521          }
522   #endif
523          if (j % FRAGBLK == 0) {         /* more (or less) free list space */
# Line 524 | Line 529 | int    i;
529                                          (j+FRAGBLK)*sizeof(BEAMI));
530                  if (newp == NULL) {
531                          f->nfrags--;    /* graceful failure */
532 <                        return;
532 >                        return(0);
533                  }
534                  f->fi = newp;
535          }
# Line 553 | Line 558 | int    i;
558                  }
559          biglob(hp)->nrd -= bi->nrd;             /* tell fragment it's free */
560          bi->nrd = 0;
561 <        bi->fo = 0;
561 >        bi->fo = 0L;
562 >        return(1);
563   }
564  
565  
# Line 587 | Line 593 | int    fd;
593   unsigned int4   nrays;
594   {
595          register struct fraglist        *f;
596 <        register int    j, k;
596 >        register int    j;
597          long    nfo;
598  
599          if (nrays == 0)
# Line 595 | Line 601 | unsigned int4  nrays;
601          DCHECK(fd < 0 | fd >= nhdfragls || !hdfragl[fd].nlinks,
602                          CONSISTENCY, "bad file descriptor in hdallocfrag");
603          f = &hdfragl[fd];
604 <        k = -1;                         /* find closest-sized fragment */
605 <        for (j = f->nfrags; j-- > 0; )
606 <                if (f->fi[j].nrd >= nrays &&
607 <                                (k < 0 || f->fi[j].nrd < f->fi[k].nrd))
602 <                        if (f->fi[k=j].nrd == nrays)
603 <                                break;
604 <        if (k < 0) {                    /* no fragment -- extend file */
604 >        for (j = f->nfrags; j-- > 0; )  /* first fit algorithm */
605 >                if (f->fi[j].nrd >= nrays)
606 >                        break;
607 >        if (j < 0) {                    /* no fragment -- extend file */
608                  nfo = f->flen;
609                  f->flen += nrays*sizeof(RAYVAL);
610          } else {                        /* else use fragment */
611 <                nfo = f->fi[k].fo;
612 <                f->fi[k].fo += nrays*sizeof(RAYVAL);
613 <                f->fi[k].nrd -= nrays;
611 >                nfo = f->fi[j].fo;
612 >                f->fi[j].fo += nrays*sizeof(RAYVAL);
613 >                f->fi[j].nrd -= nrays;
614          }
615          return(nfo);
616   }
# Line 645 | Line 648 | register int   i;
648                  hp->bi[i].fo = nfo;
649          } else
650                  hp->bi[i].fo = 0L;
651 <        biglob(hp)->nrd += hp->bi[i].nrd = nrays;
651 >        biglob(hp)->nrd += nrays - hp->bi[i].nrd;
652 >        hp->bi[i].nrd = nrays;
653          markdirty(hp, i);               /* section directory now out of date */
654          return(1);
655   }
# Line 720 | Line 724 | register int   i;
724          if (hp->bi[i].nrd) {
725                  if (hdfragflags&FF_KILL)
726                          hdfreefrag(hp, i);
727 +                biglob(hp)->nrd -= hp->bi[i].nrd;
728                  hp->bi[i].nrd = 0;      /* make sure it's gone */
729                  hp->bi[i].fo = 0L;
730          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines