--- ray/src/hd/holofile.c 2003/05/29 16:26:21 3.46 +++ ray/src/hd/holofile.c 2018/10/05 19:19:16 3.61 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: holofile.c,v 3.46 2003/05/29 16:26:21 greg Exp $"; +static const char RCSid[] = "$Id: holofile.c,v 3.61 2018/10/05 19:19:16 greg Exp $"; #endif /* * Routines for managing holodeck files @@ -7,13 +7,20 @@ static const char RCSid[] = "$Id: holofile.c,v 3.46 20 * 9/30/97 GWLarson */ +#include "copyright.h" + +#include + +#include "platform.h" +#include "rtprocess.h" + #include "holo.h" #ifndef CACHESIZE #ifdef SMLMEM -#define CACHESIZE 5 +#define CACHESIZE 10 #else -#define CACHESIZE 17 /* default cache size (Mbytes, 0==inf) */ +#define CACHESIZE 100 /* default cache size (Mbytes, 0==inf) */ #endif #endif #ifndef FREEBEAMS @@ -23,7 +30,7 @@ static const char RCSid[] = "$Id: holofile.c,v 3.46 20 #define PCTFREE 15 /* maximum fraction to free (%) */ #endif #ifndef MAXFRAGB -#define MAXFRAGB 16 /* fragment blocks/file to track (0==inf) */ +#define MAXFRAGB 64 /* fragment blocks/file to track (0==inf) */ #endif #ifndef FF_DEFAULT /* when to free a beam fragment */ @@ -35,7 +42,13 @@ static const char RCSid[] = "$Id: holofile.c,v 3.46 20 #endif #ifndef BSD +#ifdef write /* platform.h renames those for Windows */ +#undef write +#endif #define write writebuf /* safe i/o routines */ +#ifdef read +#undef read +#endif #define read readbuf #endif @@ -57,16 +70,30 @@ static struct fraglist { static int nhdfragls; /* size of hdfragl array */ +static HOLO *hdalloc(HDGRID *hproto); +static char *hdrealloc(char *ptr, unsigned siz, char *rout); +static void hdattach(int fd, int wr); +static void hdrelease(int fd); +static void hdmarkdirty(HOLO *hp, int i); +static unsigned int hdmemuse(int all); +static int hdfilord(const void *hb1, const void *hb2); +static off_t hdallocfrag(int fd, uint32 nrays); +static int hdsyncbeam(HOLO *hp, int i); +static int hdlrulist(HDBEAMI *hb, int nents, int n, HOLO *hp); +static int hdfreecache(int pct, HOLO *honly); + + HOLO * -hdalloc(hproto) /* allocate and set holodeck section based on grid */ -HDGRID *hproto; +hdalloc( /* allocate and set holodeck section based on grid */ + HDGRID *hproto +) { HOLO hdhead; - register HOLO *hp; + HOLO *hp; int n; /* copy grid to temporary header */ - bcopy((void *)hproto, (void *)&hdhead, sizeof(HDGRID)); + memcpy((void *)&hdhead, (void *)hproto, sizeof(HDGRID)); /* compute grid vectors and sizes */ hdcompgrid(&hdhead); /* allocate header with directory */ @@ -74,31 +101,32 @@ HDGRID *hproto; if ((hp = (HOLO *)malloc(n)) == NULL) return(NULL); /* copy header information */ - copystruct(hp, &hdhead); + *hp = hdhead; /* allocate and clear beam list */ hp->bl = (BEAM **)malloc((nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM)); if (hp->bl == NULL) { free((void *)hp); return(NULL); } - bzero((void *)hp->bl, (nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM)); + memset((void *)hp->bl, '\0', (nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM)); hp->bl[0] = (BEAM *)(hp->bl+nbeams(hp)+1); /* set blglob(hp) */ hp->fd = -1; hp->dirty = 0; hp->priv = NULL; /* clear beam directory */ - bzero((void *)hp->bi, (nbeams(hp)+1)*sizeof(BEAMI)); + memset((void *)hp->bi, '\0', (nbeams(hp)+1)*sizeof(BEAMI)); return(hp); /* all is well */ } char * -hdrealloc(ptr, siz, rout) /* (re)allocate memory, retry then error */ -char *ptr; -unsigned siz; -char *rout; +hdrealloc( /* (re)allocate memory, retry then error */ + char *ptr, + unsigned siz, + char *rout +) { - register char *newp; + char *newp; /* call malloc/realloc */ if (ptr == NULL) newp = (char *)malloc(siz); else newp = (char *)realloc((void *)ptr, siz); @@ -116,30 +144,35 @@ char *rout; } -hdattach(fd, wr) /* start tracking file fragments for some section */ -register int fd; -int wr; +void +hdattach( /* start tracking file fragments for some section */ + int fd, + int wr +) { if (fd >= nhdfragls) { hdfragl = (struct fraglist *)hdrealloc((char *)hdfragl, (fd+1)*sizeof(struct fraglist), "hdattach"); - bzero((void *)(hdfragl+nhdfragls), - (fd+1-nhdfragls)*sizeof(struct fraglist)); + memset((void *)(hdfragl+nhdfragls), + '\0', (fd+1-nhdfragls)*sizeof(struct fraglist)); nhdfragls = fd+1; } hdfragl[fd].nlinks++; hdfragl[fd].writable = wr; /* set writable flag */ - hdfragl[fd].flen = lseek(fd, (off_t)0L, 2); /* get file length */ + /* get file length */ + hdfragl[fd].flen = lseek(fd, (off_t)0, SEEK_END); } /* Do we need a routine to locate file fragments given known occupants? */ -hdrelease(fd) /* stop tracking file fragments for some section */ -register int fd; +void +hdrelease( /* stop tracking file fragments for some section */ + int fd +) { - if (fd < 0 | fd >= nhdfragls || !hdfragl[fd].nlinks) + if ((fd < 0) | (fd >= nhdfragls) || !hdfragl[fd].nlinks) return; if (!--hdfragl[fd].nlinks && hdfragl[fd].nfrags) { free((void *)hdfragl[fd].fi); @@ -150,18 +183,19 @@ register int fd; HOLO * -hdinit(fd, hproto) /* initialize a holodeck section in a file */ -int fd; /* corresponding file descriptor */ -HDGRID *hproto; /* holodeck section grid */ +hdinit( /* initialize a holodeck section in a file */ + int fd, /* corresponding file descriptor */ + HDGRID *hproto /* holodeck section grid */ +) { off_t rtrunc; off_t fpos; int writable; - register HOLO *hp; - register int n; + HOLO *hp; + int n; /* prepare for system errors */ errno = 0; - if ((fpos = lseek(fd, (off_t)0L, 1)) < 0) + if ((fpos = lseek(fd, (off_t)0, SEEK_CUR)) < 0) error(SYSTEM, "cannot determine holodeck file position"); if (hproto == NULL) { /* assume we're loading it */ HDGRID hpr; @@ -186,7 +220,7 @@ HDGRID *hproto; /* holodeck section grid */ if (fd < nhdfragls && hdfragl[fd].nlinks) writable = hdfragl[fd].writable; else - writable = lseek(fd, fpos, 0) == fpos && + writable = lseek(fd, fpos, SEEK_SET) == fpos && write(fd, (char *)hp, sizeof(HDGRID)) == sizeof(HDGRID); } else { /* else assume we're creating it */ @@ -209,15 +243,17 @@ HDGRID *hproto; /* holodeck section grid */ fpos = hdfilen(fd); biglob(hp)->nrd = rtrunc = 0; for (n = hproto == NULL ? nbeams(hp) : 0; n > 0; n--) - if (hp->bi[n].nrd) + if (hp->bi[n].nrd) { if (hp->bi[n].fo+hp->bi[n].nrd*sizeof(RAYVAL) > fpos) { rtrunc += hp->bi[n].nrd; hp->bi[n].nrd = 0; } else biglob(hp)->nrd += hp->bi[n].nrd; + } if (rtrunc) { sprintf(errmsg, "truncated section, %ld rays lost (%.1f%%)", - rtrunc, 100.*rtrunc/(rtrunc+biglob(hp)->nrd)); + (long)rtrunc, + 100.*rtrunc/(rtrunc+biglob(hp)->nrd)); error(WARNING, errmsg); } /* add to holodeck list */ @@ -230,20 +266,24 @@ HDGRID *hproto; /* holodeck section grid */ return(hp); memerr: error(SYSTEM, "cannot allocate holodeck grid"); + return NULL; /* pro forma return */ } -hdmarkdirty(hp, i) /* mark holodeck directory position dirty */ -register HOLO *hp; -int i; +void +hdmarkdirty( /* mark holodeck directory position dirty */ + HOLO *hp, + int i +) { static BEAMI smudge = {0, -1}; int mindist, minpos; - register int j; + int j; if (!hp->dirty++) { /* write smudge first time */ - if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI), 0) < 0 - || write(hp->fd, (char *)&smudge, + if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI), + SEEK_SET) < 0 || + write(hp->fd, (char *)&smudge, sizeof(BEAMI)) != sizeof(BEAMI)) error(SYSTEM, "seek/write error in hdmarkdirty"); hp->dirseg[0].s = i; @@ -257,7 +297,7 @@ int i; hp->dirseg[j].n = 1; break; } - copystruct(hp->dirseg+j, hp->dirseg+(j-1)); + *(hp->dirseg+j) = *(hp->dirseg+(j-1)); } do { /* check neighbors */ mindist = nbeams(hp); /* find closest */ @@ -279,17 +319,18 @@ int i; hp->dirseg[minpos].n - hp->dirseg[j].s; hp->dirty--; while (++j < hp->dirty) /* close the gap */ - copystruct(hp->dirseg+j, hp->dirseg+(j+1)); + *(hp->dirseg+j) = *(hp->dirseg+(j+1)); } while (mindist <= MINDIRSEL); } int -hdsync(hp, all) /* update beams and directory on disk */ -register HOLO *hp; -int all; +hdsync( /* update beams and directory on disk */ + HOLO *hp, + int all +) { - register int j, n; + int j, n; if (hp == NULL) { /* do all holodecks */ n = 0; @@ -306,7 +347,7 @@ int all; errno = 0; /* write dirty segments */ for (j = 0; j < hp->dirty; j++) { if (lseek(hp->fd, biglob(hp)->fo + - (hp->dirseg[j].s-1)*sizeof(BEAMI), 0) < 0) + (hp->dirseg[j].s-1)*sizeof(BEAMI), SEEK_SET) < 0) error(SYSTEM, "cannot seek on holodeck file"); n = hp->dirseg[j].n * sizeof(BEAMI); if (write(hp->fd, (char *)(hp->bi+hp->dirseg[j].s), n) != n) @@ -317,12 +358,13 @@ int all; } -unsigned -hdmemuse(all) /* return memory usage (in bytes) */ -int all; /* include overhead (painful) */ +unsigned int +hdmemuse( /* return memory usage (in bytes) */ + int all /* include overhead (painful) */ +) { long total = 0; - register int i, j; + int i, j; for (j = 0; hdlist[j] != NULL; j++) { total += blglob(hdlist[j])->nrm * sizeof(RAYVAL); @@ -347,18 +389,19 @@ int all; /* include overhead (painful) */ off_t -hdfilen(fd) /* return file length for fd */ -int fd; +hdfilen( /* return file length for fd */ + int fd +) { off_t fpos, flen; if (fd < 0) return(-1); if (fd >= nhdfragls || !hdfragl[fd].nlinks) { - if ((fpos = lseek(fd, (off_t)0L, 1)) < 0) + if ((fpos = lseek(fd, (off_t)0, SEEK_CUR)) < 0) return(-1); - flen = lseek(fd, (off_t)0L, 2); - lseek(fd, fpos, 0); + flen = lseek(fd, (off_t)0, SEEK_END); + lseek(fd, fpos, SEEK_SET); return(flen); } return(hdfragl[fd].flen); @@ -366,42 +409,42 @@ int fd; off_t -hdfiluse(fd, all) /* compute file usage (in bytes) */ -int fd; /* open file descriptor to check */ -int all; /* include overhead and unflushed data */ +hdfiluse( /* compute file usage (in bytes) */ + int fd /* open file descriptor to check */ +) { off_t total = 0; - register int i, j; + int j; for (j = 0; hdlist[j] != NULL; j++) { if (hdlist[j]->fd != fd) continue; total += biglob(hdlist[j])->nrd * sizeof(RAYVAL); - if (all) { - for (i = nbeams(hdlist[j]); i > 0; i--) - if (hdlist[j]->bl[i] != NULL) - total += sizeof(RAYVAL) * + total += nbeams(hdlist[j])*sizeof(BEAMI) + sizeof(HDGRID); +#if 0 + for (i = nbeams(hdlist[j]); i > 0; i--) + if (hdlist[j]->bl[i] != NULL) + total += sizeof(RAYVAL) * (hdlist[j]->bl[i]->nrm - hdlist[j]->bi[i].nrd); - total += sizeof(HDGRID) + - nbeams(hdlist[j])*sizeof(BEAMI); - } +#endif } - return(total); /* does not include fragments */ + return(total); /* doesn't include fragments, unflushed rays */ } RAYVAL * -hdnewrays(hp, i, nr) /* allocate space for add'l rays and return pointer */ -register HOLO *hp; -register int i; -int nr; /* number of new rays desired */ +hdnewrays( /* allocate space for add'l rays and return pointer */ + HOLO *hp, + int i, + int nr /* number of new rays desired */ +) { RAYVAL *p; int n; if (nr <= 0) return(NULL); - CHECK(i < 1 | i > nbeams(hp), + CHECK((i < 1) | (i > nbeams(hp)), CONSISTENCY, "bad beam index given to hdnewrays"); if (hp->bl[i] != NULL) hp->bl[i]->tick = hdclock; /* preempt swap */ @@ -413,7 +456,7 @@ int nr; /* number of new rays desired */ blglob(hp)->nrm += n; if ((n = hp->bl[i]->nrm = hp->bi[i].nrd)) { errno = 0; - if (lseek(hp->fd, hp->bi[i].fo, 0) < 0) + if (lseek(hp->fd, hp->bi[i].fo, SEEK_SET) < 0) error(SYSTEM, "seek error on holodeck file"); n *= sizeof(RAYVAL); if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) @@ -429,20 +472,21 @@ int nr; /* number of new rays desired */ hdfreefrag(hp, i); /* relinquish old fragment */ p = hdbray(hp->bl[i]) + hp->bl[i]->nrm; hp->bl[i]->nrm += nr; /* update in-core structure */ - bzero((void *)p, nr*sizeof(RAYVAL)); + memset((void *)p, '\0', nr*sizeof(RAYVAL)); blglob(hp)->tick = hp->bl[i]->tick = hdclock++; /* update LRU clock */ return(p); /* point to new rays */ } BEAM * -hdgetbeam(hp, i) /* get beam (from file if necessary) */ -register HOLO *hp; -register int i; +hdgetbeam( /* get beam (from file if necessary) */ + HOLO *hp, + int i +) { - register int n; + int n; - CHECK(i < 1 | i > nbeams(hp), + CHECK((i < 1) | (i > nbeams(hp)), CONSISTENCY, "bad beam index given to hdgetbeam"); if (hp->bl[i] == NULL) { /* load from disk */ if (!(n = hp->bi[i].nrd)) @@ -452,7 +496,7 @@ register int i; hp->bl[i] = (BEAM *)hdrealloc(NULL, hdbsiz(n), "hdgetbeam"); blglob(hp)->nrm += hp->bl[i]->nrm = n; errno = 0; - if (lseek(hp->fd, hp->bi[i].fo, 0) < 0) + if (lseek(hp->fd, hp->bi[i].fo, SEEK_SET) < 0) error(SYSTEM, "seek error on holodeck file"); n *= sizeof(RAYVAL); if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) @@ -466,37 +510,42 @@ register int i; int -hdfilord(hb1, hb2) /* order beams for quick loading */ -register HDBEAMI *hb1, *hb2; +hdfilord( /* order beams for quick loading */ + const void *hb1, + const void *hb2 +) { - register long c; + off_t c; /* residents go first */ - if (hb2->h->bl[hb2->b] != NULL) - return(hb1->h->bl[hb1->b] == NULL); - if (hb1->h->bl[hb1->b] != NULL) + if (((HDBEAMI*)hb2)->h->bl[((HDBEAMI*)hb2)->b] != NULL) + return(((HDBEAMI*)hb1)->h->bl[((HDBEAMI*)hb1)->b] == NULL); + if (((HDBEAMI*)hb1)->h->bl[((HDBEAMI*)hb1)->b] != NULL) return(-1); /* otherwise sort by file descriptor */ - if ((c = hb1->h->fd - hb2->h->fd)) - return(c); + if (((HDBEAMI*)hb1)->h->fd != ((HDBEAMI*)hb2)->h->fd) + return(((HDBEAMI*)hb1)->h->fd - ((HDBEAMI*)hb2)->h->fd); /* then by position in file */ - c = hb1->h->bi[hb1->b].fo - hb2->h->bi[hb2->b].fo; + c = ((HDBEAMI*)hb1)->h->bi[((HDBEAMI*)hb1)->b].fo + - ((HDBEAMI*)hb2)->h->bi[((HDBEAMI*)hb2)->b].fo; return(c > 0 ? 1 : c < 0 ? -1 : 0); } -hdloadbeams(hb, n, bf) /* load a list of beams in optimal order */ -register HDBEAMI *hb; /* list gets sorted by hdfilord() */ -int n; /* list length */ -int (*bf)(); /* callback function (optional) */ +void +hdloadbeams( /* load a list of beams in optimal order */ + HDBEAMI *hb, /* list gets sorted by hdfilord() */ + int n, /* list length */ + void (*bf)(BEAM *bp, HDBEAMI *hb) /* callback function (optional) */ +) { unsigned origcachesize, memuse; int bytesloaded, needbytes, bytes2free; - register BEAM *bp; - register int i; + BEAM *bp; + int i; /* precheck consistency */ if (n <= 0) return; for (i = n; i--; ) - if (hb[i].h==NULL || hb[i].b<1 | hb[i].b>nbeams(hb[i].h)) + if (hb[i].h==NULL || (hb[i].b<1) | (hb[i].b>nbeams(hb[i].h))) error(CONSISTENCY, "bad beam in hdloadbeams"); /* sort list for optimal access */ qsort((void *)hb, n, sizeof(HDBEAMI), hdfilord); @@ -530,13 +579,14 @@ int (*bf)(); /* callback function (optional) */ int -hdfreefrag(hp, i) /* free a file fragment */ -HOLO *hp; -int i; +hdfreefrag( /* free a file fragment */ + HOLO *hp, + int i +) { - register BEAMI *bi = &hp->bi[i]; - register struct fraglist *f; - register int j, k; + BEAMI *bi = &hp->bi[i]; + struct fraglist *f; + int j, k; if (bi->nrd <= 0) return(0); @@ -551,7 +601,7 @@ int i; if (++k >= f->nfrags) goto endloop; if (k > j) - copystruct(f->fi+j, f->fi+k); + *(f->fi+j) = *(f->fi+k); } endloop: f->nfrags = j; @@ -565,7 +615,7 @@ int i; } #endif if (j % FRAGBLK == 0) { /* more (or less) free list space */ - register BEAMI *newp; + BEAMI *newp; if (f->fi == NULL) newp = (BEAMI *)malloc((j+FRAGBLK)*sizeof(BEAMI)); else @@ -583,7 +633,7 @@ int i; f->fi[j].nrd = bi->nrd; break; } - copystruct(f->fi+j, f->fi+(j-1)); + *(f->fi+j) = *(f->fi+(j-1)); } /* coalesce adjacent fragments */ /* successors never empty */ @@ -602,22 +652,23 @@ int i; } biglob(hp)->nrd -= bi->nrd; /* tell fragment it's free */ bi->nrd = 0; - bi->fo = 0L; + bi->fo = 0; hdmarkdirty(hp, i); /* assume we'll reallocate */ return(1); } int -hdfragOK(fd, listlen, listsiz) /* get fragment list status for file */ -int fd; -int *listlen; -register int4 *listsiz; +hdfragOK( /* get fragment list status for file */ + int fd, + int *listlen, + int32 *listsiz +) { - register struct fraglist *f; - register int i; + struct fraglist *f; + int i; - if (fd < 0 | fd >= nhdfragls || !(f = &hdfragl[fd])->nlinks) + if ((fd < 0) | (fd >= nhdfragls) || !(f = &hdfragl[fd])->nlinks) return(0); /* listless */ if (listlen != NULL) *listlen = f->nfrags; @@ -633,12 +684,13 @@ register int4 *listsiz; off_t -hdallocfrag(fd, nrays) /* allocate a file fragment */ -int fd; -unsigned int4 nrays; +hdallocfrag( /* allocate a file fragment */ + int fd, + uint32 nrays +) { - register struct fraglist *f; - register int j; + struct fraglist *f; + int j; off_t nfo; if (nrays == 0) @@ -662,12 +714,13 @@ unsigned int4 nrays; int -hdsyncbeam(hp, i) /* sync beam in memory with beam on disk */ -register HOLO *hp; -register int i; +hdsyncbeam( /* sync beam in memory with beam on disk */ + HOLO *hp, + int i +) { int fragfreed; - unsigned int4 nrays; + uint32 nrays; unsigned int n; off_t nfo; /* check file status */ @@ -683,7 +736,7 @@ register int i; if (nrays) { /* get and write new fragment */ nfo = hdallocfrag(hp->fd, nrays); errno = 0; - if (lseek(hp->fd, nfo, 0) < 0) + if (lseek(hp->fd, nfo, SEEK_SET) < 0) error(SYSTEM, "cannot seek on holodeck file"); n = hp->bl[i]->nrm * sizeof(RAYVAL); if (write(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) { @@ -693,7 +746,7 @@ register int i; } hp->bi[i].fo = nfo; } else - hp->bi[i].fo = 0L; + hp->bi[i].fo = 0; biglob(hp)->nrd += nrays - hp->bi[i].nrd; hp->bi[i].nrd = nrays; if (!fragfreed) @@ -703,9 +756,10 @@ register int i; int -hdfreebeam(hp, i) /* free beam, writing if dirty */ -register HOLO *hp; -register int i; +hdfreebeam( /* free beam, writing if dirty */ + HOLO *hp, + int i +) { int nchanged; @@ -744,9 +798,10 @@ register int i; int -hdkillbeam(hp, i) /* delete beam from holodeck */ -register HOLO *hp; -register int i; +hdkillbeam( /* delete beam from holodeck */ + HOLO *hp, + int i +) { int nchanged; @@ -757,7 +812,7 @@ register int i; return(nchanged); } if (i == 0) { /* clobber entire holodeck */ - if (biglob(hp)->nrd == 0 & blglob(hp)->nrm == 0) + if ((biglob(hp)->nrd == 0) & (blglob(hp)->nrm == 0)) return(0); /* already empty */ nchanged = 0; nchanged = 0; @@ -781,7 +836,7 @@ register int i; if (hp->bi[i].nrd && !(hdfragflags&FF_KILL && hdfreefrag(hp,i))) { biglob(hp)->nrd -= hp->bi[i].nrd; /* free failed */ hp->bi[i].nrd = 0; - hp->bi[i].fo = 0L; + hp->bi[i].fo = 0; hdmarkdirty(hp, i); } return(nchanged); @@ -789,13 +844,14 @@ register int i; int -hdlrulist(hb, nents, n, hp) /* add beams from holodeck to LRU list */ -register HDBEAMI *hb; /* beam list */ -int nents; /* current list length */ -int n; /* maximum list length */ -register HOLO *hp; /* section we're adding from */ +hdlrulist( /* add beams from holodeck to LRU list */ + HDBEAMI *hb, /* beam list */ + int nents, /* current list length */ + int n, /* maximum list length */ + HOLO *hp /* section we're adding from */ +) { - register int i, j; + int i, j; /* insert each beam from hp */ for (i = 1; i <= nbeams(hp); i++) { if (hp->bl[i] == NULL) /* check if loaded */ @@ -813,7 +869,7 @@ register HOLO *hp; /* section we're adding from */ hb[j].b = i; break; } - copystruct(hb+j, hb+(j-1)); + *(hb+j) = *(hb+(j-1)); } } return(nents); /* return new list length */ @@ -821,14 +877,15 @@ register HOLO *hp; /* section we're adding from */ int -hdfreecache(pct, honly) /* free up cache space, writing changes */ -int pct; /* maximum percentage to free */ -register HOLO *honly; /* NULL means check all */ +hdfreecache( /* free up cache space, writing changes */ + int pct, /* maximum percentage to free */ + HOLO *honly /* NULL means check all */ +) { HDBEAMI hb[FREEBEAMS]; int freetarget; int n; - register int i; + int i; #ifdef DEBUG unsigned membefore; @@ -864,10 +921,12 @@ register HOLO *honly; /* NULL means check all */ } -hddone(hp) /* clean up holodeck section and free */ -register HOLO *hp; /* NULL means clean up all */ +void +hddone( /* clean up holodeck section and free */ + HOLO *hp /* NULL means clean up all */ +) { - register int i; + int i; if (hp == NULL) { /* NULL means clean up everything */ while (hdlist[0] != NULL)