Browse Source

struct variable, #2/18, reorder struct variable field initialisation

pre-master-46
rlar 10 years ago
parent
commit
01a0449420
  1. 18
      src/frontend/options.c
  2. 2
      src/frontend/spiceif.c
  3. 4
      src/frontend/variable.c

18
src/frontend/options.c

@ -52,8 +52,8 @@ cp_enqvar(char *word)
if (d->v_length == 1) { if (d->v_length == 1) {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_next = NULL;
vv->va_name = copy(word); vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_REAL; vv->va_type = CP_REAL;
if (isreal(d)) if (isreal(d))
vv->va_real = d->v_realdata[0]; vv->va_real = d->v_realdata[0];
@ -61,19 +61,19 @@ cp_enqvar(char *word)
vv->va_real = realpart(d->v_compdata[0]); vv->va_real = realpart(d->v_compdata[0]);
} else { } else {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_next = NULL;
vv->va_name = copy(word); vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_LIST; vv->va_type = CP_LIST;
vv->va_vlist = NULL; vv->va_vlist = NULL;
for (i = d->v_length; --i >= 0;) { for (i = d->v_length; --i >= 0;) {
tv = TMALLOC(struct variable, 1); tv = TMALLOC(struct variable, 1);
tv->va_name = NULL; tv->va_name = NULL;
tv->va_next = vv->va_vlist;
tv->va_type = CP_REAL; tv->va_type = CP_REAL;
if (isreal(d)) if (isreal(d))
tv->va_real = d->v_realdata[i]; tv->va_real = d->v_realdata[i];
else else
tv->va_real = realpart(d->v_compdata[i]); tv->va_real = realpart(d->v_compdata[i]);
tv->va_next = vv->va_vlist;
vv->va_vlist = tv; vv->va_vlist = tv;
} }
} }
@ -91,40 +91,40 @@ cp_enqvar(char *word)
return (vv); return (vv);
if (eq(word, "curplotname")) { if (eq(word, "curplotname")) {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_next = NULL;
vv->va_name = copy(word); vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_STRING; vv->va_type = CP_STRING;
vv->va_string = copy(plot_cur->pl_name); vv->va_string = copy(plot_cur->pl_name);
} else if (eq(word, "curplottitle")) { } else if (eq(word, "curplottitle")) {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_next = NULL;
vv->va_name = copy(word); vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_STRING; vv->va_type = CP_STRING;
vv->va_string = copy(plot_cur->pl_title); vv->va_string = copy(plot_cur->pl_title);
} else if (eq(word, "curplotdate")) { } else if (eq(word, "curplotdate")) {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_next = NULL;
vv->va_name = copy(word); vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_STRING; vv->va_type = CP_STRING;
vv->va_string = copy(plot_cur->pl_date); vv->va_string = copy(plot_cur->pl_date);
} else if (eq(word, "curplot")) { } else if (eq(word, "curplot")) {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_next = NULL;
vv->va_name = copy(word); vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_STRING; vv->va_type = CP_STRING;
vv->va_string = copy(plot_cur->pl_typename); vv->va_string = copy(plot_cur->pl_typename);
} else if (eq(word, "plots")) { } else if (eq(word, "plots")) {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_next = NULL;
vv->va_name = copy(word); vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_LIST; vv->va_type = CP_LIST;
vv->va_vlist = NULL; vv->va_vlist = NULL;
for (pl = plot_list; pl; pl = pl->pl_next) { for (pl = plot_list; pl; pl = pl->pl_next) {
tv = TMALLOC(struct variable, 1); tv = TMALLOC(struct variable, 1);
tv->va_name = NULL; tv->va_name = NULL;
tv->va_next = vv->va_vlist;
tv->va_type = CP_STRING; tv->va_type = CP_STRING;
tv->va_string = copy(pl->pl_typename); tv->va_string = copy(pl->pl_typename);
tv->va_next = vv->va_vlist;
vv->va_vlist = tv; vv->va_vlist = tv;
} }
} }

2
src/frontend/spiceif.c

@ -987,9 +987,9 @@ parmtovar(IFvalue *pv, IFparm *opt)
nv = TMALLOC(struct variable, 1); nv = TMALLOC(struct variable, 1);
nv->va_name = NULL; nv->va_name = NULL;
nv->va_next = vv->va_vlist; nv->va_next = vv->va_vlist;
vv->va_vlist = nv;
nv->va_type = CP_REAL; nv->va_type = CP_REAL;
nv->va_real = pv->v.vec.rVec[i]; nv->va_real = pv->v.vec.rVec[i];
vv->va_vlist = nv;
} }
/* It is a linked list where the first node is a variable /* It is a linked list where the first node is a variable
* pointing to the different values of the variables. * pointing to the different values of the variables.

4
src/frontend/variable.c

@ -284,9 +284,9 @@ cp_setparse(wordlist *wl)
if ((!wl || (*wl->wl_word != '=')) && !strchr(name, '=')) { if ((!wl || (*wl->wl_word != '=')) && !strchr(name, '=')) {
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_name = copy(name); vv->va_name = copy(name);
vv->va_next = vars;
vv->va_type = CP_BOOL; vv->va_type = CP_BOOL;
vv->va_bool = TRUE; vv->va_bool = TRUE;
vv->va_next = vars;
vars = vv; vars = vv;
tfree(name); /*DG: cp_unquote Memory leak*/ tfree(name); /*DG: cp_unquote Memory leak*/
continue; continue;
@ -377,9 +377,9 @@ cp_setparse(wordlist *wl)
vv = TMALLOC(struct variable, 1); vv = TMALLOC(struct variable, 1);
vv->va_name = copy(name); vv->va_name = copy(name);
vv->va_next = vars;
vv->va_type = CP_LIST; vv->va_type = CP_LIST;
vv->va_vlist = listv; vv->va_vlist = listv;
vv->va_next = vars;
vars = vv; vars = vv;
wl = wl->wl_next; wl = wl->wl_next;

Loading…
Cancel
Save