--- ray/src/hd/rhoptimize.c 2003/02/22 02:07:25 3.8 +++ ray/src/hd/rhoptimize.c 2003/07/21 22:30:18 3.14 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rhoptimize.c,v 3.8 2003/02/22 02:07:25 greg Exp $"; +static const char RCSid[] = "$Id: rhoptimize.c,v 3.14 2003/07/21 22:30:18 schorsch Exp $"; #endif /* * Optimize holodeck for quick access. @@ -7,10 +7,12 @@ static const char RCSid[] = "$Id: rhoptimize.c,v 3.8 2 * 11/4/98 Greg Ward Larson */ -#include "holo.h" - #include +#include +#include "rtprocess.h" /* getpid() */ +#include "holo.h" + #ifndef BKBSIZE #define BKBSIZE 256 /* beam clump size (kilobytes) */ #endif @@ -19,7 +21,6 @@ char *progname; char tempfile[128]; int dupchecking = 0; -extern char *rindex(); extern long rhinitcopy(); @@ -52,7 +53,7 @@ char *argv[]; error(SYSTEM, errmsg); } strcpy(tempfile, inpname); - if ((outname = rindex(tempfile, '/')) != NULL) + if ((outname = strrchr(tempfile, '/')) != NULL) outname++; else outname = tempfile; @@ -67,11 +68,11 @@ char *argv[]; lseek(hdfd[0], (off_t)nextipos, 0); read(hdfd[0], (char *)&nextipos, sizeof(nextipos)); /* get output position; set last */ - thisopos = lseek(hdfd[1], (off_t)0L, 2); + thisopos = lseek(hdfd[1], (off_t)0, 2); if (lastopos > 0L) { lseek(hdfd[1], (off_t)lastopos, 0); write(hdfd[1], (char *)&thisopos, sizeof(thisopos)); - lseek(hdfd[1], (off_t)0L, 2); + lseek(hdfd[1], (off_t)0, 2); } lastopos = thisopos; thisopos = 0L; /* write place holder */ @@ -157,9 +158,9 @@ int n; rva[i].r[1][0]==rva[j].r[1][0] && rva[i].r[1][1]==rva[j].r[1][1] ) { n--; /* swap duplicate with end */ - copystruct(&rtmp, rva+n); - copystruct(rva+n, rva+i); - copystruct(rva+i, &rtmp); + rtmp = *(rva+n); + *(rva+n) = *(rva+i); + *(rva+i) = rtmp; i--; /* recheck one we swapped */ } return(n); @@ -172,7 +173,7 @@ static int bpcmp(b1p, b2p) /* compare beam positions on disk */ int *b1p, *b2p; { - register long pdif = beamdir[*b1p].fo - beamdir[*b2p].fo; + register off_t pdif = beamdir[*b1p].fo - beamdir[*b2p].fo; if (pdif < 0L) return(-1); return(pdif > 0L); @@ -190,13 +191,13 @@ int *bq, nb; int n; beamdir = hp->bi; /* sort based on file position */ - qsort((char *)bq, nb, sizeof(*bq), bpcmp); + qsort((void *)bq, nb, sizeof(*bq), bpcmp); /* transfer and free each beam */ for (i = 0; i < nb; i++) { bp = hdgetbeam(hp, bq[i]); DCHECK(bp==NULL, CONSISTENCY, "empty beam in xferclump"); n = dupchecking ? nuniq(hdbray(bp),bp->nrm) : bp->nrm; - bcopy((char *)hdbray(bp), (char *)hdnewrays(hout,bq[i],n), + memcpy((void *)hdnewrays(hout,bq[i],n),(void *)hdbray(bp), n*sizeof(RAYVAL)); hdfreebeam(hp, bq[i]); }