diff --git a/src/frontend/options.c b/src/frontend/options.c index 6967c1f08..70d7d6994 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -58,12 +58,8 @@ cp_enqvar(char *word) vv->va_type = CP_REAL; vv->va_real = value; } else { + struct variable *list = NULL; int i; - vv = TMALLOC(struct variable, 1); - vv->va_name = copy(word); - vv->va_next = NULL; - vv->va_type = CP_LIST; - vv->va_vlist = NULL; for (i = d->v_length; --i >= 0;) { double value = isreal(d) ? d->v_realdata[i] @@ -71,11 +67,16 @@ cp_enqvar(char *word) struct variable *tv; tv = TMALLOC(struct variable, 1); tv->va_name = NULL; - tv->va_next = vv->va_vlist; + tv->va_next = list; tv->va_type = CP_REAL; tv->va_real = value; - vv->va_vlist = tv; + list = tv; } + vv = TMALLOC(struct variable, 1); + vv->va_name = copy(word); + vv->va_next = NULL; + vv->va_type = CP_LIST; + vv->va_vlist = list; } if (d->v_link2) @@ -114,21 +115,22 @@ cp_enqvar(char *word) vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_typename); } else if (eq(word, "plots")) { + struct variable *list = NULL; struct plot *pl; - vv = TMALLOC(struct variable, 1); - vv->va_name = copy(word); - vv->va_next = NULL; - vv->va_type = CP_LIST; - vv->va_vlist = NULL; for (pl = plot_list; pl; pl = pl->pl_next) { struct variable *tv; tv = TMALLOC(struct variable, 1); tv->va_name = NULL; - tv->va_next = vv->va_vlist; + tv->va_next = list; tv->va_type = CP_STRING; tv->va_string = copy(pl->pl_typename); - vv->va_vlist = tv; + list = tv; } + vv = TMALLOC(struct variable, 1); + vv->va_name = copy(word); + vv->va_next = NULL; + vv->va_type = CP_LIST; + vv->va_vlist = list; } if (vv) return (vv); diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index f35546eec..2e7cf837a 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -993,21 +993,22 @@ parmtovar(IFvalue *pv, IFparm *opt) vv->va_bool = pv->iValue ? TRUE : FALSE; return vv; case IF_REALVEC: { + struct variable *list = NULL; int i; - vv = TMALLOC(struct variable, 1); - vv->va_name = copy(opt->description); - vv->va_next = NULL; - vv->va_type = CP_LIST; - vv->va_vlist = NULL; for (i = pv->v.numValue; --i >= 0;) { struct variable *nv; nv = TMALLOC(struct variable, 1); nv->va_name = NULL; - nv->va_next = vv->va_vlist; + nv->va_next = list; nv->va_type = CP_REAL; nv->va_real = pv->v.vec.rVec[i]; - vv->va_vlist = nv; + list = nv; } + vv = TMALLOC(struct variable, 1); + vv->va_name = copy(opt->description); + vv->va_next = NULL; + vv->va_type = CP_LIST; + vv->va_vlist = list; return vv; /* It is a linked list where the first node is a variable * pointing to the different values of the variables.