From 01a04494208943a716c53ba1aefe69cbcd3a60e7 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 25 Mar 2016 15:35:20 +0100 Subject: [PATCH] struct variable, #2/18, reorder struct variable field initialisation --- src/frontend/options.c | 18 +++++++++--------- src/frontend/spiceif.c | 2 +- src/frontend/variable.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/frontend/options.c b/src/frontend/options.c index 8e5984d2b..cf112052f 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -52,8 +52,8 @@ cp_enqvar(char *word) if (d->v_length == 1) { vv = TMALLOC(struct variable, 1); - vv->va_next = NULL; vv->va_name = copy(word); + vv->va_next = NULL; vv->va_type = CP_REAL; if (isreal(d)) vv->va_real = d->v_realdata[0]; @@ -61,19 +61,19 @@ cp_enqvar(char *word) vv->va_real = realpart(d->v_compdata[0]); } else { vv = TMALLOC(struct variable, 1); - vv->va_next = NULL; 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;) { tv = TMALLOC(struct variable, 1); tv->va_name = NULL; + tv->va_next = vv->va_vlist; tv->va_type = CP_REAL; if (isreal(d)) tv->va_real = d->v_realdata[i]; else tv->va_real = realpart(d->v_compdata[i]); - tv->va_next = vv->va_vlist; vv->va_vlist = tv; } } @@ -91,40 +91,40 @@ cp_enqvar(char *word) return (vv); if (eq(word, "curplotname")) { vv = TMALLOC(struct variable, 1); - vv->va_next = NULL; vv->va_name = copy(word); + vv->va_next = NULL; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_name); } else if (eq(word, "curplottitle")) { vv = TMALLOC(struct variable, 1); - vv->va_next = NULL; vv->va_name = copy(word); + vv->va_next = NULL; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_title); } else if (eq(word, "curplotdate")) { vv = TMALLOC(struct variable, 1); - vv->va_next = NULL; vv->va_name = copy(word); + vv->va_next = NULL; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_date); } else if (eq(word, "curplot")) { vv = TMALLOC(struct variable, 1); - vv->va_next = NULL; vv->va_name = copy(word); + vv->va_next = NULL; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_typename); } else if (eq(word, "plots")) { vv = TMALLOC(struct variable, 1); - vv->va_next = NULL; 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) { tv = TMALLOC(struct variable, 1); tv->va_name = NULL; + tv->va_next = vv->va_vlist; tv->va_type = CP_STRING; tv->va_string = copy(pl->pl_typename); - tv->va_next = vv->va_vlist; vv->va_vlist = tv; } } diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index a8cf877d8..8297fd6b0 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -987,9 +987,9 @@ parmtovar(IFvalue *pv, IFparm *opt) nv = TMALLOC(struct variable, 1); nv->va_name = NULL; nv->va_next = vv->va_vlist; - vv->va_vlist = nv; nv->va_type = CP_REAL; nv->va_real = pv->v.vec.rVec[i]; + vv->va_vlist = nv; } /* It is a linked list where the first node is a variable * pointing to the different values of the variables. diff --git a/src/frontend/variable.c b/src/frontend/variable.c index 8245b1e44..232abe2a6 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -284,9 +284,9 @@ cp_setparse(wordlist *wl) if ((!wl || (*wl->wl_word != '=')) && !strchr(name, '=')) { vv = TMALLOC(struct variable, 1); vv->va_name = copy(name); + vv->va_next = vars; vv->va_type = CP_BOOL; vv->va_bool = TRUE; - vv->va_next = vars; vars = vv; tfree(name); /*DG: cp_unquote Memory leak*/ continue; @@ -377,9 +377,9 @@ cp_setparse(wordlist *wl) vv = TMALLOC(struct variable, 1); vv->va_name = copy(name); + vv->va_next = vars; vv->va_type = CP_LIST; vv->va_vlist = listv; - vv->va_next = vars; vars = vv; wl = wl->wl_next;