--- ray/src/hd/rhoptimize.c 2003/05/29 16:26:22 3.10 +++ ray/src/hd/rhoptimize.c 2003/10/22 02:06:34 3.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rhoptimize.c,v 3.10 2003/05/29 16:26:22 greg Exp $"; +static const char RCSid[] = "$Id: rhoptimize.c,v 3.17 2003/10/22 02:06:34 greg Exp $"; #endif /* * Optimize holodeck for quick access. @@ -7,10 +7,13 @@ static const char RCSid[] = "$Id: rhoptimize.c,v 3.10 * 11/4/98 Greg Ward Larson */ -#include "holo.h" - #include +#include +#include "platform.h" +#include "rtprocess.h" /* getpid() */ +#include "holo.h" + #ifndef BKBSIZE #define BKBSIZE 256 /* beam clump size (kilobytes) */ #endif @@ -19,7 +22,6 @@ char *progname; char tempfile[128]; int dupchecking = 0; -extern char *rindex(); extern long rhinitcopy(); @@ -37,7 +39,7 @@ char *argv[]; dupchecking++; argv++; argc--; } - if (argc < 1 | argc > 2) { + if ((argc < 1) | (argc > 2)) { fprintf(stderr, "Usage: %s [-u] input.hdk [output.hdk]\n", progname); exit(1); @@ -52,7 +54,7 @@ char *argv[]; error(SYSTEM, errmsg); } strcpy(tempfile, inpname); - if ((outname = rindex(tempfile, '/')) != NULL) + if ((outname = strrchr(tempfile, '/')) != NULL) outname++; else outname = tempfile; @@ -64,14 +66,14 @@ char *argv[]; lastopos = 0L; /* copy sections one by one */ while (nextipos != 0L) { /* set input position; get next */ - lseek(hdfd[0], (off_t)nextipos, 0); + lseek(hdfd[0], (off_t)nextipos, SEEK_SET); 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, SEEK_END); if (lastopos > 0L) { - lseek(hdfd[1], (off_t)lastopos, 0); + lseek(hdfd[1], (off_t)lastopos, SEEK_SET); write(hdfd[1], (char *)&thisopos, sizeof(thisopos)); - lseek(hdfd[1], (off_t)0L, 2); + lseek(hdfd[1], (off_t)0, SEEK_END); } lastopos = thisopos; thisopos = 0L; /* write place holder */ @@ -157,9 +159,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); @@ -196,7 +198,7 @@ int *bq, nb; bp = hdgetbeam(hp, bq[i]); DCHECK(bp==NULL, CONSISTENCY, "empty beam in xferclump"); n = dupchecking ? nuniq(hdbray(bp),bp->nrm) : bp->nrm; - bcopy((void *)hdbray(bp), (void *)hdnewrays(hout,bq[i],n), + memcpy((void *)hdnewrays(hout,bq[i],n),(void *)hdbray(bp), n*sizeof(RAYVAL)); hdfreebeam(hp, bq[i]); }