--- ray/src/rt/data.c 1992/11/22 10:47:51 2.6 +++ ray/src/rt/data.c 1994/04/14 04:50:27 2.8 @@ -1,4 +1,4 @@ -/* Copyright (c) 1992 Regents of the University of California */ +/* Copyright (c) 1993 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -18,15 +18,25 @@ static char SCCSid[] = "$SunId$ LBL"; #include "data.h" + /* picture memory usage before warning */ +#ifndef PSIZWARN +#ifdef BIGMEM +#define PSIZWARN 3000000 +#else +#define PSIZWARN 1000000 +#endif +#endif +#ifndef TABSIZ #define TABSIZ 97 /* table size (prime) */ +#endif #define hash(s) (shash(s)%TABSIZ) extern char *fgetword(); -extern char *libpath; /* library search path */ +extern char *getlibpath(); /* library search path */ static DATARRAY *dtab[TABSIZ]; /* data array list */ @@ -68,7 +78,7 @@ char *dname; * 0 0 ni p0i p1i .. pni */ - if ((dfname = getpath(dname, libpath, R_OK)) == NULL) { + if ((dfname = getpath(dname, getlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find data file \"%s\"", dname); error(USER, errmsg); } @@ -159,7 +169,6 @@ DATARRAY * getpict(pname) /* get picture pname */ char *pname; { - extern char *libpath; double inpaspect; char *pfname; FILE *fp; @@ -175,7 +184,7 @@ char *pname; if (!strcmp(pname, pp->name)) return(pp); /* found! */ - if ((pfname = getpath(pname, libpath, R_OK)) == NULL) { + if ((pfname = getpath(pname, getlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find picture file \"%s\"", pname); error(USER, errmsg); } @@ -198,6 +207,15 @@ char *pname; getheader(fp, headaspect, &inpaspect); if (!fgetsresolu(&inpres, fp)) goto readerr; +#if PSIZWARN + /* check memory usage */ + i = 3*sizeof(DATATYPE)*inpres.xr*inpres.yr; + if (i > PSIZWARN) { + sprintf(errmsg, "picture file \"%s\" using %d bytes of memory", + pname, i); + error(WARNING, errmsg); + } +#endif for (i = 0; i < 3; i++) { pp[i].nd = 2; pp[i].dim[0].ne = inpres.yr;