ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/data.c
(Generate patch)

Comparing ray/src/rt/data.c (file contents):
Revision 2.4 by greg, Thu Nov 12 10:11:51 1992 UTC vs.
Revision 2.5 by greg, Sun Nov 22 10:02:57 1992 UTC

# Line 45 | Line 45 | char  *dname;
45  
46          /*
47           *      If we haven't loaded the data already, we will look
48 <         *  for it in the directorys specified by the library path.
48 >         *  for it in the directories specified by the library path.
49           *
50           *      The file has the following format:
51           *
# Line 248 | Line 248 | readerr:
248   freedata(dname)                 /* free memory associated with dname */
249   char  *dname;
250   {
251 +        DATARRAY  head;
252          register DATARRAY  *dp, *dpl;
253          register int  i;
254  
255 <        for (dpl = NULL, dp = dlist; dp != NULL; dpl = dp, dp = dp->next)
256 <                if (!strcmp(dname, dp->name)) {
257 <                        if (dpl == NULL)
258 <                                dlist = dp->next;
259 <                        else
259 <                                dpl->next = dp->next;
255 >        head.next = dlist;
256 >        dpl = &head;
257 >        while ((dp = dpl->next) != NULL)
258 >                if (dname == NULL || !strcmp(dname, dp->name)) {
259 >                        dpl->next = dp->next;
260                          free((char *)dp->arr);
261                          for (i = 0; i < dp->nd; i++)
262                                  if (dp->dim[i].p != NULL)
263                                          free((char *)dp->dim[i].p);
264                          freestr(dp->name);
265                          free((char *)dp);
266 <                        return;
267 <                }
266 >                } else
267 >                        dpl = dp;
268 >        dlist = head.next;
269   }
270  
271  
272   freepict(pname)                 /* free memory associated with pname */
273   char  *pname;
274   {
275 +        DATARRAY  head;
276          register DATARRAY  *pp, *ppl;
277  
278 <        for (ppl = NULL, pp = plist; pp != NULL; ppl = pp, pp = pp->next)
279 <                if (!strcmp(pname, pp->name)) {
280 <                        if (ppl == NULL)
281 <                                plist = pp->next;
282 <                        else
281 <                                ppl->next = pp->next;
278 >        head.next = plist;
279 >        ppl = &head;
280 >        while ((pp = ppl->next) != NULL)
281 >                if (pname == NULL || !strcmp(pname, pp->name)) {
282 >                        ppl->next = pp->next;
283                          free((char *)pp[0].arr);
284                          free((char *)pp[1].arr);
285                          free((char *)pp[2].arr);
286                          freestr(pp[0].name);
287                          free((char *)pp);
288 <                        return;
289 <                }
288 >                } else
289 >                        ppl = pp;
290 >        plist = head.next;
291   }
292  
293  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines