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.50 by greg, Mon Jul 7 17:21:50 2003 UTC vs.
Revision 3.59 by greg, Fri Sep 3 23:52:42 2010 UTC

# Line 11 | Line 11 | static const char      RCSid[] = "$Id$";
11  
12   #include <string.h>
13  
14 + #include "platform.h"
15 + #include "rtprocess.h"
16 +
17   #include "holo.h"
18  
19   #ifndef CACHESIZE
20   #ifdef SMLMEM
21 < #define CACHESIZE       5
21 > #define CACHESIZE       10
22   #else
23 < #define CACHESIZE       17      /* default cache size (Mbytes, 0==inf) */
23 > #define CACHESIZE       100     /* default cache size (Mbytes, 0==inf) */
24   #endif
25   #endif
26   #ifndef FREEBEAMS
# Line 27 | Line 30 | static const char      RCSid[] = "$Id$";
30   #define PCTFREE         15      /* maximum fraction to free (%) */
31   #endif
32   #ifndef MAXFRAGB
33 < #define MAXFRAGB        16      /* fragment blocks/file to track (0==inf) */
33 > #define MAXFRAGB        64      /* fragment blocks/file to track (0==inf) */
34   #endif
35   #ifndef FF_DEFAULT
36                                  /* when to free a beam fragment */
# Line 61 | Line 64 | static struct fraglist {
64  
65   static int      nhdfragls;      /* size of hdfragl array */
66  
67 + static HOLO *hdalloc(HDGRID *hproto);
68 + static char *hdrealloc(char *ptr, unsigned siz, char *rout);
69 + static void hdattach(int fd, int wr);
70 + static void hdrelease(int fd);
71 + static void hdmarkdirty(HOLO *hp, int i);
72 + static unsigned int hdmemuse(int all);
73 + static int hdfilord(const void *hb1, const void *hb2);
74 + static off_t hdallocfrag(int fd, uint32 nrays);
75 + static int hdsyncbeam(HOLO *hp, int i);
76 + static int hdlrulist(HDBEAMI *hb, int nents, int n, HOLO *hp);
77 + static int hdfreecache(int pct, HOLO *honly);
78  
79 +
80 +
81   HOLO *
82 < hdalloc(hproto)         /* allocate and set holodeck section based on grid */
83 < HDGRID  *hproto;
82 > hdalloc(                /* allocate and set holodeck section based on grid */
83 >        HDGRID  *hproto
84 > )
85   {
86          HOLO    hdhead;
87          register HOLO   *hp;
# Line 78 | Line 95 | HDGRID *hproto;
95          if ((hp = (HOLO *)malloc(n)) == NULL)
96                  return(NULL);
97                                  /* copy header information */
98 <        copystruct(hp, &hdhead);
98 >        *hp = hdhead;
99                                  /* allocate and clear beam list */
100          hp->bl = (BEAM **)malloc((nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM));
101          if (hp->bl == NULL) {
# Line 97 | Line 114 | HDGRID *hproto;
114  
115  
116   char *
117 < hdrealloc(ptr, siz, rout)       /* (re)allocate memory, retry then error */
118 < char    *ptr;
119 < unsigned        siz;
120 < char    *rout;
117 > hdrealloc(      /* (re)allocate memory, retry then error */
118 >        char    *ptr,
119 >        unsigned        siz,
120 >        char    *rout
121 > )
122   {
123          register char   *newp;
124                                          /* call malloc/realloc */
# Line 120 | Line 138 | char   *rout;
138   }
139  
140  
141 < hdattach(fd, wr)        /* start tracking file fragments for some section */
142 < register int    fd;
143 < int     wr;
141 > void
142 > hdattach(       /* start tracking file fragments for some section */
143 >        register int    fd,
144 >        int     wr
145 > )
146   {
147          if (fd >= nhdfragls) {
148                  hdfragl = (struct fraglist *)hdrealloc((char *)hdfragl,
# Line 133 | Line 153 | int    wr;
153          }
154          hdfragl[fd].nlinks++;
155          hdfragl[fd].writable = wr;              /* set writable flag */
156 <        hdfragl[fd].flen = lseek(fd, (off_t)0, 2);      /* get file length */
156 >                                                /* get file length */
157 >        hdfragl[fd].flen = lseek(fd, (off_t)0, SEEK_END);
158   }
159  
160  
161   /* Do we need a routine to locate file fragments given known occupants? */
162  
163  
164 < hdrelease(fd)           /* stop tracking file fragments for some section */
165 < register int    fd;
164 > void
165 > hdrelease(              /* stop tracking file fragments for some section */
166 >        register int    fd
167 > )
168   {
169 <        if (fd < 0 | fd >= nhdfragls || !hdfragl[fd].nlinks)
169 >        if ((fd < 0) | (fd >= nhdfragls) || !hdfragl[fd].nlinks)
170                  return;
171          if (!--hdfragl[fd].nlinks && hdfragl[fd].nfrags) {
172                  free((void *)hdfragl[fd].fi);
# Line 153 | Line 176 | register int   fd;
176   }
177  
178  
179 < HOLO *
180 < hdinit(fd, hproto)      /* initialize a holodeck section in a file */
181 < int     fd;                     /* corresponding file descriptor */
182 < HDGRID  *hproto;                /* holodeck section grid */
179 > extern HOLO *
180 > hdinit( /* initialize a holodeck section in a file */
181 >        int     fd,                     /* corresponding file descriptor */
182 >        HDGRID  *hproto         /* holodeck section grid */
183 > )
184   {
185          off_t   rtrunc;
186          off_t   fpos;
# Line 165 | Line 189 | HDGRID *hproto;                /* holodeck section grid */
189          register int    n;
190                                          /* prepare for system errors */
191          errno = 0;
192 <        if ((fpos = lseek(fd, (off_t)0, 1)) < 0)
192 >        if ((fpos = lseek(fd, (off_t)0, SEEK_CUR)) < 0)
193                  error(SYSTEM, "cannot determine holodeck file position");
194          if (hproto == NULL) {           /* assume we're loading it */
195                  HDGRID  hpr;
# Line 190 | Line 214 | HDGRID *hproto;                /* holodeck section grid */
214                  if (fd < nhdfragls && hdfragl[fd].nlinks)
215                          writable = hdfragl[fd].writable;
216                  else
217 <                        writable = lseek(fd, fpos, 0) == fpos &&
217 >                        writable = lseek(fd, fpos, SEEK_SET) == fpos &&
218                                  write(fd, (char *)hp, sizeof(HDGRID)) ==
219                                                          sizeof(HDGRID);
220          } else {                        /* else assume we're creating it */
# Line 213 | Line 237 | HDGRID *hproto;                /* holodeck section grid */
237          fpos = hdfilen(fd);
238          biglob(hp)->nrd = rtrunc = 0;
239          for (n = hproto == NULL ? nbeams(hp) : 0; n > 0; n--)
240 <                if (hp->bi[n].nrd)
240 >                if (hp->bi[n].nrd) {
241                          if (hp->bi[n].fo+hp->bi[n].nrd*sizeof(RAYVAL) > fpos) {
242                                  rtrunc += hp->bi[n].nrd;
243                                  hp->bi[n].nrd = 0;
244                          } else
245                                  biglob(hp)->nrd += hp->bi[n].nrd;
246 +                }
247          if (rtrunc) {
248                  sprintf(errmsg, "truncated section, %ld rays lost (%.1f%%)",
249 <                                rtrunc, 100.*rtrunc/(rtrunc+biglob(hp)->nrd));
249 >                                (long)rtrunc,
250 >                                100.*rtrunc/(rtrunc+biglob(hp)->nrd));
251                  error(WARNING, errmsg);
252          }
253                                          /* add to holodeck list */
# Line 234 | Line 260 | HDGRID *hproto;                /* holodeck section grid */
260          return(hp);
261   memerr:
262          error(SYSTEM, "cannot allocate holodeck grid");
263 +        return NULL; /* pro forma return */
264   }
265  
266  
267 < hdmarkdirty(hp, i)              /* mark holodeck directory position dirty */
268 < register HOLO   *hp;
269 < int     i;
267 > void
268 > hdmarkdirty(            /* mark holodeck directory position dirty */
269 >        register HOLO   *hp,
270 >        int     i
271 > )
272   {
273          static BEAMI    smudge = {0, -1};
274          int     mindist, minpos;
275          register int    j;
276  
277          if (!hp->dirty++) {                     /* write smudge first time */
278 <                if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI), 0) < 0
279 <                                || write(hp->fd, (char *)&smudge,
278 >                if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI),
279 >                                        SEEK_SET) < 0 ||
280 >                                write(hp->fd, (char *)&smudge,
281                                          sizeof(BEAMI)) != sizeof(BEAMI))
282                          error(SYSTEM, "seek/write error in hdmarkdirty");
283                  hp->dirseg[0].s = i;
# Line 261 | Line 291 | int    i;
291                          hp->dirseg[j].n = 1;
292                          break;
293                  }
294 <                copystruct(hp->dirseg+j, hp->dirseg+(j-1));
294 >                *(hp->dirseg+j) = *(hp->dirseg+(j-1));
295          }
296          do {                            /* check neighbors */
297                  mindist = nbeams(hp);           /* find closest */
# Line 283 | Line 313 | int    i;
313                                          hp->dirseg[minpos].n - hp->dirseg[j].s;
314                  hp->dirty--;
315                  while (++j < hp->dirty)         /* close the gap */
316 <                        copystruct(hp->dirseg+j, hp->dirseg+(j+1));
316 >                        *(hp->dirseg+j) = *(hp->dirseg+(j+1));
317          } while (mindist <= MINDIRSEL);
318   }
319  
320  
321 < int
322 < hdsync(hp, all)                 /* update beams and directory on disk */
323 < register HOLO   *hp;
324 < int     all;
321 > extern int
322 > hdsync(                 /* update beams and directory on disk */
323 >        register HOLO   *hp,
324 >        int     all
325 > )
326   {
327          register int    j, n;
328  
# Line 310 | Line 341 | int    all;
341          errno = 0;                      /* write dirty segments */
342          for (j = 0; j < hp->dirty; j++) {
343                  if (lseek(hp->fd, biglob(hp)->fo +
344 <                                (hp->dirseg[j].s-1)*sizeof(BEAMI), 0) < 0)
344 >                            (hp->dirseg[j].s-1)*sizeof(BEAMI), SEEK_SET) < 0)
345                          error(SYSTEM, "cannot seek on holodeck file");
346                  n = hp->dirseg[j].n * sizeof(BEAMI);
347                  if (write(hp->fd, (char *)(hp->bi+hp->dirseg[j].s), n) != n)
# Line 321 | Line 352 | int    all;
352   }
353  
354  
355 < unsigned
356 < hdmemuse(all)           /* return memory usage (in bytes) */
357 < int     all;                    /* include overhead (painful) */
355 > unsigned int
356 > hdmemuse(               /* return memory usage (in bytes) */
357 >        int     all                     /* include overhead (painful) */
358 > )
359   {
360          long    total = 0;
361          register int    i, j;
# Line 350 | Line 382 | int    all;                    /* include overhead (painful) */
382   }
383  
384  
385 < off_t
386 < hdfilen(fd)             /* return file length for fd */
387 < int     fd;
385 > extern off_t
386 > hdfilen(                /* return file length for fd */
387 >        int     fd
388 > )
389   {
390          off_t   fpos, flen;
391  
392          if (fd < 0)
393                  return(-1);
394          if (fd >= nhdfragls || !hdfragl[fd].nlinks) {
395 <                if ((fpos = lseek(fd, (off_t)0, 1)) < 0)
395 >                if ((fpos = lseek(fd, (off_t)0, SEEK_CUR)) < 0)
396                          return(-1);
397 <                flen = lseek(fd, (off_t)0, 2);
398 <                lseek(fd, fpos, 0);
397 >                flen = lseek(fd, (off_t)0, SEEK_END);
398 >                lseek(fd, fpos, SEEK_SET);
399                  return(flen);
400          }
401          return(hdfragl[fd].flen);
402   }
403  
404  
405 < off_t
406 < hdfiluse(fd, all)       /* compute file usage (in bytes) */
407 < int     fd;                     /* open file descriptor to check */
408 < int     all;                    /* include overhead and unflushed data */
405 > extern off_t
406 > hdfiluse(       /* compute file usage (in bytes) */
407 >        int     fd                      /* open file descriptor to check */
408 > )
409   {
410          off_t   total = 0;
411 <        register int    i, j;
411 >        register int    j;
412  
413          for (j = 0; hdlist[j] != NULL; j++) {
414                  if (hdlist[j]->fd != fd)
415                          continue;
416                  total += biglob(hdlist[j])->nrd * sizeof(RAYVAL);
417 <                if (all) {
418 <                        for (i = nbeams(hdlist[j]); i > 0; i--)
419 <                                if (hdlist[j]->bl[i] != NULL)
420 <                                        total += sizeof(RAYVAL) *
417 >                total += nbeams(hdlist[j])*sizeof(BEAMI) + sizeof(HDGRID);
418 > #if 0
419 >                for (i = nbeams(hdlist[j]); i > 0; i--)
420 >                        if (hdlist[j]->bl[i] != NULL)
421 >                                total += sizeof(RAYVAL) *
422                                                  (hdlist[j]->bl[i]->nrm -
423                                                  hdlist[j]->bi[i].nrd);
424 <                        total += sizeof(HDGRID) +
391 <                                        nbeams(hdlist[j])*sizeof(BEAMI);
392 <                }
424 > #endif
425          }
426 <        return(total);          /* does not include fragments */
426 >        return(total);          /* doesn't include fragments, unflushed rays */
427   }
428  
429  
430 < RAYVAL *
431 < hdnewrays(hp, i, nr)    /* allocate space for add'l rays and return pointer */
432 < register HOLO   *hp;
433 < register int    i;
434 < int     nr;                     /* number of new rays desired */
430 > extern RAYVAL *
431 > hdnewrays(      /* allocate space for add'l rays and return pointer */
432 >        register HOLO   *hp,
433 >        register int    i,
434 >        int     nr                      /* number of new rays desired */
435 > )
436   {
437          RAYVAL  *p;
438          int     n;
439  
440          if (nr <= 0) return(NULL);
441 <        CHECK(i < 1 | i > nbeams(hp),
441 >        CHECK((i < 1) | (i > nbeams(hp)),
442                          CONSISTENCY, "bad beam index given to hdnewrays");
443          if (hp->bl[i] != NULL)
444                  hp->bl[i]->tick = hdclock;      /* preempt swap */
# Line 417 | Line 450 | int    nr;                     /* number of new rays desired */
450                  blglob(hp)->nrm += n;
451                  if ((n = hp->bl[i]->nrm = hp->bi[i].nrd)) {
452                          errno = 0;
453 <                        if (lseek(hp->fd, hp->bi[i].fo, 0) < 0)
453 >                        if (lseek(hp->fd, hp->bi[i].fo, SEEK_SET) < 0)
454                                  error(SYSTEM, "seek error on holodeck file");
455                          n *= sizeof(RAYVAL);
456                          if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n)
# Line 439 | Line 472 | int    nr;                     /* number of new rays desired */
472   }
473  
474  
475 < BEAM *
476 < hdgetbeam(hp, i)        /* get beam (from file if necessary) */
477 < register HOLO   *hp;
478 < register int    i;
475 > extern BEAM *
476 > hdgetbeam(      /* get beam (from file if necessary) */
477 >        register HOLO   *hp,
478 >        register int    i
479 > )
480   {
481          register int    n;
482  
483 <        CHECK(i < 1 | i > nbeams(hp),
483 >        CHECK((i < 1) | (i > nbeams(hp)),
484                          CONSISTENCY, "bad beam index given to hdgetbeam");
485          if (hp->bl[i] == NULL) {                /* load from disk */
486                  if (!(n = hp->bi[i].nrd))
# Line 456 | Line 490 | register int   i;
490                  hp->bl[i] = (BEAM *)hdrealloc(NULL, hdbsiz(n), "hdgetbeam");
491                  blglob(hp)->nrm += hp->bl[i]->nrm = n;
492                  errno = 0;
493 <                if (lseek(hp->fd, hp->bi[i].fo, 0) < 0)
493 >                if (lseek(hp->fd, hp->bi[i].fo, SEEK_SET) < 0)
494                          error(SYSTEM, "seek error on holodeck file");
495                  n *= sizeof(RAYVAL);
496                  if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n)
# Line 470 | Line 504 | register int   i;
504  
505  
506   int
507 < hdfilord(hb1, hb2)      /* order beams for quick loading */
508 < register HDBEAMI        *hb1, *hb2;
507 > hdfilord(       /* order beams for quick loading */
508 >        register const void     *hb1,
509 >        register const void     *hb2
510 > )
511   {
512          register off_t  c;
513                                  /* residents go first */
514 <        if (hb2->h->bl[hb2->b] != NULL)
515 <                return(hb1->h->bl[hb1->b] == NULL);
516 <        if (hb1->h->bl[hb1->b] != NULL)
514 >        if (((HDBEAMI*)hb2)->h->bl[((HDBEAMI*)hb2)->b] != NULL)
515 >                return(((HDBEAMI*)hb1)->h->bl[((HDBEAMI*)hb1)->b] == NULL);
516 >        if (((HDBEAMI*)hb1)->h->bl[((HDBEAMI*)hb1)->b] != NULL)
517                  return(-1);
518                                  /* otherwise sort by file descriptor */
519 <        if (hb1->h->fd != hb2->h->fd)
520 <                return(hb1->h->fd - hb2->h->fd);
519 >        if (((HDBEAMI*)hb1)->h->fd != ((HDBEAMI*)hb2)->h->fd)
520 >                return(((HDBEAMI*)hb1)->h->fd - ((HDBEAMI*)hb2)->h->fd);
521                                  /* then by position in file */
522 <        c = hb1->h->bi[hb1->b].fo - hb2->h->bi[hb2->b].fo;
522 >        c = ((HDBEAMI*)hb1)->h->bi[((HDBEAMI*)hb1)->b].fo
523 >                - ((HDBEAMI*)hb2)->h->bi[((HDBEAMI*)hb2)->b].fo;
524          return(c > 0 ? 1 : c < 0 ? -1 : 0);
525   }
526  
527  
528 < hdloadbeams(hb, n, bf)  /* load a list of beams in optimal order */
529 < register HDBEAMI        *hb;    /* list gets sorted by hdfilord() */
530 < int     n;                      /* list length */
531 < void    (*bf)();                /* callback function (optional) */
528 > extern void
529 > hdloadbeams(    /* load a list of beams in optimal order */
530 >        register HDBEAMI        *hb,    /* list gets sorted by hdfilord() */
531 >        int     n,                      /* list length */
532 >        void    (*bf)(BEAM *bp, HDBEAMI *hb)    /* callback function (optional) */
533 > )
534   {
535          unsigned        origcachesize, memuse;
536          int     bytesloaded, needbytes, bytes2free;
# Line 500 | Line 539 | void   (*bf)();                /* callback function (optional) */
539                                          /* precheck consistency */
540          if (n <= 0) return;
541          for (i = n; i--; )
542 <                if (hb[i].h==NULL || hb[i].b<1 | hb[i].b>nbeams(hb[i].h))
542 >                if (hb[i].h==NULL || (hb[i].b<1) | (hb[i].b>nbeams(hb[i].h)))
543                          error(CONSISTENCY, "bad beam in hdloadbeams");
544                                          /* sort list for optimal access */
545          qsort((void *)hb, n, sizeof(HDBEAMI), hdfilord);
# Line 533 | Line 572 | void   (*bf)();                /* callback function (optional) */
572   }
573  
574  
575 < int
576 < hdfreefrag(hp, i)                       /* free a file fragment */
577 < HOLO    *hp;
578 < int     i;
575 > extern int
576 > hdfreefrag(                     /* free a file fragment */
577 >        HOLO    *hp,
578 >        int     i
579 > )
580   {
581          register BEAMI  *bi = &hp->bi[i];
582          register struct fraglist        *f;
# Line 555 | Line 595 | int    i;
595                                  if (++k >= f->nfrags)
596                                          goto endloop;
597                          if (k > j)
598 <                                copystruct(f->fi+j, f->fi+k);
598 >                                *(f->fi+j) = *(f->fi+k);
599                  }
600          endloop:
601                  f->nfrags = j;
# Line 587 | Line 627 | int    i;
627                          f->fi[j].nrd = bi->nrd;
628                          break;
629                  }
630 <                copystruct(f->fi+j, f->fi+(j-1));
630 >                *(f->fi+j) = *(f->fi+(j-1));
631          }
632                                          /* coalesce adjacent fragments */
633                                                  /* successors never empty */
# Line 612 | Line 652 | int    i;
652   }
653  
654  
655 < int
656 < hdfragOK(fd, listlen, listsiz)  /* get fragment list status for file */
657 < int     fd;
658 < int     *listlen;
659 < register int32  *listsiz;
655 > extern int
656 > hdfragOK(       /* get fragment list status for file */
657 >        int     fd,
658 >        int     *listlen,
659 >        register int32  *listsiz
660 > )
661   {
662          register struct fraglist        *f;
663          register int    i;
664  
665 <        if (fd < 0 | fd >= nhdfragls || !(f = &hdfragl[fd])->nlinks)
665 >        if ((fd < 0) | (fd >= nhdfragls) || !(f = &hdfragl[fd])->nlinks)
666                  return(0);              /* listless */
667          if (listlen != NULL)
668                  *listlen = f->nfrags;
# Line 637 | Line 678 | register int32 *listsiz;
678  
679  
680   off_t
681 < hdallocfrag(fd, nrays)          /* allocate a file fragment */
682 < int     fd;
683 < uint32  nrays;
681 > hdallocfrag(            /* allocate a file fragment */
682 >        int     fd,
683 >        uint32  nrays
684 > )
685   {
686          register struct fraglist        *f;
687          register int    j;
# Line 666 | Line 708 | uint32 nrays;
708  
709  
710   int
711 < hdsyncbeam(hp, i)               /* sync beam in memory with beam on disk */
712 < register HOLO   *hp;
713 < register int    i;
711 > hdsyncbeam(             /* sync beam in memory with beam on disk */
712 >        register HOLO   *hp,
713 >        register int    i
714 > )
715   {
716          int     fragfreed;
717          uint32  nrays;
# Line 687 | Line 730 | register int   i;
730          if (nrays) {                    /* get and write new fragment */
731                  nfo = hdallocfrag(hp->fd, nrays);
732                  errno = 0;
733 <                if (lseek(hp->fd, nfo, 0) < 0)
733 >                if (lseek(hp->fd, nfo, SEEK_SET) < 0)
734                          error(SYSTEM, "cannot seek on holodeck file");
735                  n = hp->bl[i]->nrm * sizeof(RAYVAL);
736                  if (write(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) {
# Line 706 | Line 749 | register int   i;
749   }
750  
751  
752 < int
753 < hdfreebeam(hp, i)               /* free beam, writing if dirty */
754 < register HOLO   *hp;
755 < register int    i;
752 > extern int
753 > hdfreebeam(             /* free beam, writing if dirty */
754 >        register HOLO   *hp,
755 >        register int    i
756 > )
757   {
758          int     nchanged;
759  
# Line 747 | Line 791 | register int   i;
791   }
792  
793  
794 < int
795 < hdkillbeam(hp, i)               /* delete beam from holodeck */
796 < register HOLO   *hp;
797 < register int    i;
794 > extern int
795 > hdkillbeam(             /* delete beam from holodeck */
796 >        register HOLO   *hp,
797 >        register int    i
798 > )
799   {
800          int     nchanged;
801  
# Line 761 | Line 806 | register int   i;
806                  return(nchanged);
807          }
808          if (i == 0) {                   /* clobber entire holodeck */
809 <                if (biglob(hp)->nrd == 0 & blglob(hp)->nrm == 0)
809 >                if ((biglob(hp)->nrd == 0) & (blglob(hp)->nrm == 0))
810                          return(0);              /* already empty */
811                  nchanged = 0;
812                  nchanged = 0;
# Line 793 | Line 838 | register int   i;
838  
839  
840   int
841 < hdlrulist(hb, nents, n, hp)     /* add beams from holodeck to LRU list */
842 < register HDBEAMI        *hb;            /* beam list */
843 < int     nents;                          /* current list length */
844 < int     n;                              /* maximum list length */
845 < register HOLO   *hp;                    /* section we're adding from */
841 > hdlrulist(      /* add beams from holodeck to LRU list */
842 >        register HDBEAMI        *hb,            /* beam list */
843 >        int     nents,                          /* current list length */
844 >        int     n,                              /* maximum list length */
845 >        register HOLO   *hp                     /* section we're adding from */
846 > )
847   {
848          register int    i, j;
849                                          /* insert each beam from hp */
# Line 817 | Line 863 | register HOLO  *hp;                    /* section we're adding from */
863                                  hb[j].b = i;
864                                  break;
865                          }
866 <                        copystruct(hb+j, hb+(j-1));
866 >                        *(hb+j) = *(hb+(j-1));
867                  }
868          }
869          return(nents);                  /* return new list length */
# Line 825 | Line 871 | register HOLO  *hp;                    /* section we're adding from */
871  
872  
873   int
874 < hdfreecache(pct, honly)         /* free up cache space, writing changes */
875 < int     pct;                            /* maximum percentage to free */
876 < register HOLO   *honly;                 /* NULL means check all */
874 > hdfreecache(            /* free up cache space, writing changes */
875 >        int     pct,                            /* maximum percentage to free */
876 >        register HOLO   *honly                  /* NULL means check all */
877 > )
878   {
879          HDBEAMI hb[FREEBEAMS];
880          int     freetarget;
# Line 868 | Line 915 | register HOLO  *honly;                 /* NULL means check all */
915   }
916  
917  
918 < hddone(hp)              /* clean up holodeck section and free */
919 < register HOLO   *hp;            /* NULL means clean up all */
918 > extern void
919 > hddone(         /* clean up holodeck section and free */
920 >        register HOLO   *hp             /* NULL means clean up all */
921 > )
922   {
923          register int    i;
924  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines