--- ray/src/rt/data.c 1992/09/21 12:07:42 2.3 +++ ray/src/rt/data.c 1992/11/22 10:02:57 2.5 @@ -45,7 +45,7 @@ char *dname; /* * If we haven't loaded the data already, we will look - * for it in the directorys specified by the library path. + * for it in the directories specified by the library path. * * The file has the following format: * @@ -139,14 +139,13 @@ scanerr: } -static double inpaspect; /* aspect ratio of input picture */ - static -headaspect(s) /* check string for aspect ratio */ +headaspect(s, iap) /* check string for aspect ratio */ char *s; +double *iap; { if (isaspect(s)) - inpaspect *= aspectval(s); + *iap *= aspectval(s); } @@ -155,6 +154,7 @@ getpict(pname) /* get picture pname */ char *pname; { extern char *libpath; + double inpaspect; char *pfname; FILE *fp; COLOR *scanin; @@ -189,7 +189,7 @@ char *pname; #endif /* get dimensions */ inpaspect = 1.0; - getheader(fp, headaspect); + getheader(fp, headaspect, &inpaspect); if (!fgetsresolu(&inpres, fp)) goto readerr; for (i = 0; i < 3; i++) { @@ -248,44 +248,46 @@ readerr: freedata(dname) /* free memory associated with dname */ char *dname; { + DATARRAY head; register DATARRAY *dp, *dpl; register int i; - for (dpl = NULL, dp = dlist; dp != NULL; dpl = dp, dp = dp->next) - if (!strcmp(dname, dp->name)) { - if (dpl == NULL) - dlist = dp->next; - else - dpl->next = dp->next; + head.next = dlist; + dpl = &head; + while ((dp = dpl->next) != NULL) + if (dname == NULL || !strcmp(dname, dp->name)) { + dpl->next = dp->next; free((char *)dp->arr); for (i = 0; i < dp->nd; i++) if (dp->dim[i].p != NULL) free((char *)dp->dim[i].p); freestr(dp->name); free((char *)dp); - return; - } + } else + dpl = dp; + dlist = head.next; } freepict(pname) /* free memory associated with pname */ char *pname; { + DATARRAY head; register DATARRAY *pp, *ppl; - for (ppl = NULL, pp = plist; pp != NULL; ppl = pp, pp = pp->next) - if (!strcmp(pname, pp->name)) { - if (ppl == NULL) - plist = pp->next; - else - ppl->next = pp->next; + head.next = plist; + ppl = &head; + while ((pp = ppl->next) != NULL) + if (pname == NULL || !strcmp(pname, pp->name)) { + ppl->next = pp->next; free((char *)pp[0].arr); free((char *)pp[1].arr); free((char *)pp[2].arr); freestr(pp[0].name); free((char *)pp); - return; - } + } else + ppl = pp; + plist = head.next; }