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

Comparing ray/src/common/caldefn.c (file contents):
Revision 2.37 by greg, Sun Oct 1 18:02:23 2023 UTC vs.
Revision 2.38 by greg, Fri Feb 23 03:47:57 2024 UTC

# Line 58 | Line 58 | static VARDEF  *htpos;                 /* ...dfirst() and */
58   static EPNODE  *ochpos;                 /* ...dnext */
59   static EPNODE  *outchan;
60  
61 + static int  optimized = 0;              /* are we optimized? */
62 +
63   EPNODE  *curfunc = NULL;
64  
65  
# Line 181 | Line 183 | dclear(                        /* delete variable definitions of name */
183      while ((vp = varlookup(name)) != NULL &&
184                  (dp = vp->def) != NULL && dp->type == '=') {
185          vp->def = dp->sibling;
186 <        epfree(dp);
186 >        epfree(dp,1);
187          varfree(vp);
188      }
189   }
# Line 195 | Line 197 | dremove(                       /* delete all definitions of name */
197      EPNODE  *ep;
198  
199      while ((ep = dpop(name)) != NULL)
200 <        epfree(ep);
200 >        epfree(ep,1);
201   }
202  
203  
# Line 356 | Line 358 | chanout(                       /* set output channels */
358  
359  
360   void
361 + doptimize(int activate)         /* optimize current and future definitions? */
362 + {
363 +    EPNODE      *ep;
364 +
365 +    if (activate && optimized)
366 +        return;                 /* already going */
367 +
368 +    if (!(optimized = activate))
369 +        return;                 /* switching off */
370 +
371 +    for (ep = dfirst(); ep != NULL; ep = dnext())
372 +        epoptimize(ep);
373 + }
374 +
375 +
376 + void
377   dcleanup(               /* clear definitions (0->vars,1->output,2->consts) */
378          int  lvl
379   )
# Line 376 | Line 394 | dcleanup(              /* clear definitions (0->vars,1->output,2->
394          while (outchan != NULL) {
395              ep = outchan;
396              outchan = ep->sibling;
397 <            ep->sibling = NULL;
380 <            epfree(ep);
397 >            epfree(ep,1);
398          }
399   }
400  
# Line 560 | Line 577 | addchan(                       /* add an output channel assignment */
577                  sp->sibling = ep;
578              else {
579                  sp->sibling = ep->sibling;
580 <                epfree(ep);
580 >                epfree(ep,1);
581              }
582              return;
583          }
# Line 614 | Line 631 | getstatement(void)                     /* get next statement */
631              syntax("';' expected");
632          scan();
633      }
634 +    if (optimized)
635 +        epoptimize(ep);                 /* optimize new statement */
636   }
637  
638  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines