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

Comparing ray/src/cv/mgflib/xf.c (file contents):
Revision 1.11 by greg, Wed Nov 29 16:45:10 1995 UTC vs.
Revision 1.12 by greg, Wed Nov 29 19:55:45 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 25 | Line 25 | XF_SPEC        *xf_context;            /* current context */
25   char    **xf_argend;            /* end of transform argument list */
26   static char     **xf_argbeg;    /* beginning of transform argument list */
27  
28 static XF_SPEC  *new_xf();
29 static long     comp_xfid();
30 static int      put_oname();
28  
32
29   int
30   xf_handler(ac, av)              /* handle xf entity */
31   int     ac;
# Line 46 | Line 42 | char   **av;
42                  if (spec->xarr != NULL) {       /* check for iteration */
43                          register struct xf_array        *ap = spec->xarr;
44  
45 <                        (void)put_oname((struct xf_array *)NULL);
45 >                        (void)xf_aname((struct xf_array *)NULL);
46                          n = ap->ndim;
47                          while (n--) {
48                                  if (++ap->aarg[n].i < ap->aarg[n].n)
# Line 58 | Line 54 | char   **av;
54                                  if ((rv = mg_fgoto(&ap->spos)) != MG_OK)
55                                          return(rv);
56                                  sprintf(ap->aarg[n].arg, "%d", ap->aarg[n].i);
57 <                                (void)put_oname(ap);
58 <                        } else
63 <                                free((MEM_PTR)ap);
57 >                                (void)xf_aname(ap);
58 >                        }
59                  }
60                  if (n < 0) {                    /* pop transform */
61                          xf_context = spec->prev;
62 <                        free((MEM_PTR)spec);
62 >                        free_xf(spec);
63                          return(MG_OK);
64                  }
65          } else {                        /* else allocate transform */
66                  if ((spec = new_xf(ac-1, av+1)) == NULL)
67                          return(MG_EMEM);
68 +                if (spec->xarr != NULL)
69 +                        (void)xf_aname(spec->xarr);
70                  spec->prev = xf_context;        /* push onto stack */
71                  xf_context = spec;
72          }
73                                          /* translate new specification */
74          n = xf_ac(spec);
75 <        if (spec->prev != NULL)         /* incremental comp. is more eff. */
79 <                n -= xf_ac(spec->prev);
75 >        n -= xf_ac(spec->prev);         /* incremental comp. is more eff. */
76          if (xf(&spec->xf, n, xf_av(spec)) != n)
77                  return(MG_ETYPE);
78                                          /* check for vertex reversal */
# Line 93 | Line 89 | char   **av;
89   }
90  
91  
92 < static XF_SPEC *
92 > XF_SPEC *
93   new_xf(ac, av)                  /* allocate new transform structure */
94   int     ac;
95   char    **av;
# Line 151 | Line 147 | char   **av;
147                          xf_av(spec)[i] = strcpy(cp, av[i]);
148                          cp += strlen(av[i]) + 1;
149                  }
154        if (spec->xarr != NULL)
155                (void)put_oname(spec->xarr);
150          return(spec);
151   }
152  
153  
154 < static int
155 < put_oname(ap)                   /* put out name for this instance */
154 > void
155 > free_xf(spec)                   /* free a transform */
156 > register XF_SPEC        *spec;
157 > {
158 >        if (spec->xarr != NULL)
159 >                free((MEM_PTR)spec->xarr);
160 >        free((MEM_PTR)spec);
161 > }
162 >
163 >
164 > int
165 > xf_aname(ap)                    /* put out name for this instance */
166   register struct xf_array        *ap;
167   {
168          static char     oname[10*XF_MAXDIM];
# Line 180 | Line 184 | register struct xf_array       *ap;
184   }
185  
186  
187 < static long
187 > long
188   comp_xfid(xfm)                  /* compute unique ID from matrix */
189   register MAT4   xfm;
190   {
# Line 212 | Line 216 | xf_clear()                     /* clear transform stack */
216          }
217          while ((spec = xf_context) != NULL) {
218                  xf_context = spec->prev;
219 <                if (spec->xarr != NULL)
216 <                        free((MEM_PTR)spec->xarr);
217 <                free((MEM_PTR)spec);
219 >                free_xf(spec);
220          }
221   }
222  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines