From 88239474a82c4779b538c9864fc18aae550f46c0 Mon Sep 17 00:00:00 2001 From: stefanjones Date: Wed, 16 Jul 2003 12:46:18 +0000 Subject: [PATCH] 2003-07-16 Stefan Jones * src/frontend/{com_compose.c,cpitf.c,device.c,subckt.c,vectors.c} src/frontend/plotting/plotit.c src/include/ngspice.h src/spicelib/parser/{inp2dot.c,inp2r.c,inpdomod.c,inpdpar.c,inpgmod.c,inppas3.c} : Rest of the serious deck reader leaks, plus fixes for the last batch. --- ChangeLog | 7 ++++ src/frontend/com_compose.c | 2 +- src/frontend/cpitf.c | 14 +++++--- src/frontend/device.c | 5 ++- src/frontend/plotting/plotit.c | 52 ++++++++++++++++++------------ src/frontend/subckt.c | 41 ++++++++++++++--------- src/frontend/vectors.c | 6 ++-- src/include/ngspice.h | 3 ++ src/spicelib/parser/inp2dot.c | 59 +++++++++++++++++++++------------- src/spicelib/parser/inp2r.c | 2 ++ src/spicelib/parser/inpdomod.c | 2 ++ src/spicelib/parser/inpdpar.c | 32 ++++++++++++------ src/spicelib/parser/inpgmod.c | 2 ++ src/spicelib/parser/inppas3.c | 11 ++++--- 14 files changed, 155 insertions(+), 83 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee166419f..88fb1fdbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-07-16 Stefan Jones + + * src/frontend/{com_compose.c,cpitf.c,device.c,subckt.c,vectors.c} + src/frontend/plotting/plotit.c src/include/ngspice.h + src/spicelib/parser/{inp2dot.c,inp2r.c,inpdomod.c,inpdpar.c,inpgmod.c,inppas3.c} : + Rest of the serious deck reader leaks, plus fixes for the last batch. + 2003-07-15 Stefan Jones * /src/frontend/{com_let.c,com_set.c,evaluate.c,parse.c,variable.c} diff --git a/src/frontend/com_compose.c b/src/frontend/com_compose.c index 1e0ee732e..18ee66785 100644 --- a/src/frontend/com_compose.c +++ b/src/frontend/com_compose.c @@ -141,7 +141,6 @@ com_compose(wordlist *wl) ; pn = pn->pn_next; } - free_pnode(first_pn); /* Now make sure these are all of the same dimensionality. We * can coerce the sizes... */ @@ -479,6 +478,7 @@ com_compose(wordlist *wl) result->v_dims[0] = length; vec_new(result); cp_addkword(CT_VECTOR, result->v_name); + free_pnode(first_pn); tfree(resname);/*DG: resname has been copied so its remains allocated: memory leak One can remove this and not copy resname*/ return; } diff --git a/src/frontend/cpitf.c b/src/frontend/cpitf.c index 4e869eabd..50b880220 100644 --- a/src/frontend/cpitf.c +++ b/src/frontend/cpitf.c @@ -265,23 +265,27 @@ cp_istrue(wordlist *wl) pn = ft_getpnames(wl, TRUE); v = ft_evaluate(pn); - free_pnode(pn); /* It makes no sense to say while (all), but what the heck... */ while (v) { if (isreal(v)) { for (i = 0; i < v->v_length; i++) - if (v->v_realdata[i] != 0.0) - return (TRUE); + if (v->v_realdata[i] != 0.0) { + free_pnode(pn); + return (TRUE); + } } else { for (i = 0; i < v->v_length; i++) if ((realpart(&v->v_compdata[i]) != 0.0) || - (imagpart(&v->v_compdata[i]) != 0.0)) + (imagpart(&v->v_compdata[i]) != 0.0)) { + free_pnode(pn); return (TRUE); + } } v = v->v_link2; } - return (FALSE); + free_pnode(pn); + return (FALSE); } /* This gets called before every command is executed... */ diff --git a/src/frontend/device.c b/src/frontend/device.c index 09667aa9b..1da120ba5 100644 --- a/src/frontend/device.c +++ b/src/frontend/device.c @@ -637,7 +637,6 @@ com_alter_common(wordlist *wl, int do_model) return; } dv = ft_evaluate(names); - free_pnode(names); if (!dv) return; if (dv->v_length < 1) { @@ -647,8 +646,8 @@ com_alter_common(wordlist *wl, int do_model) if_setparam(ft_curckt->ci_ckt, &dev, param, dv, do_model); - /* Vector data (dv) should get garbage-collected. */ - + free_pnode(names); + return; } diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index f7327e0d6..db737cff0 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -254,8 +254,11 @@ plotit(wordlist *wl, char *hcopy, char *devname) double *newdata, *newscale; double tstep, tstart, tstop, ttime; + /* return value, error by default */ + bool rtn = FALSE; + if (!wl) - return FALSE; + goto quit1; wl_root = wl; /* First get the command line, without the limits. */ @@ -264,8 +267,10 @@ plotit(wordlist *wl, char *hcopy, char *devname) (void) getlims(wwl, "xlimit", 2); (void) getlims(wwl, "yl", 2); (void) getlims(wwl, "ylimit", 2); - (void) sprintf(cline, "plot %s", wl_flatten(wwl)); - + pname = wl_flatten(wwl); + (void) sprintf(cline, "plot %s", pname); + tfree(pname); + wl_free(wwl); /* Now extract all the parameters. */ @@ -516,9 +521,10 @@ plotit(wordlist *wl, char *hcopy, char *devname) nointerp = TRUE; wl = wl->wl_next; + tfree(tw); if (!wl) { fprintf(cp_err, "Error: no vectors given\n"); - return (FALSE); + goto quit1; } wl->wl_prev = NULL; @@ -534,7 +540,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) names = ft_getpnames(wl, FALSE); if (names == NULL) - return (FALSE); + goto quit1; /* Now evaluate the names. */ for (n = names, lv = NULL; n; n = n->pn_next) { @@ -542,16 +548,16 @@ plotit(wordlist *wl, char *hcopy, char *devname) eq(n->pn_value->v_name, "vs")) { if (!lv) { fprintf(cp_err, "Error: misplaced vs arg\n"); - return (FALSE); + goto quit; } else { if (!(n = n->pn_next)) { fprintf(cp_err, "Error: missing vs arg\n"); - return (FALSE); + goto quit; } dv = ft_evaluate(n); if (!dv) - return (FALSE); + goto quit; if (lastvs) lv = lastvs->v_link2; else @@ -566,7 +572,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) } dv = ft_evaluate(n); if (!dv) - return (FALSE); + goto quit; if (!d) vecs = dv; else @@ -575,7 +581,6 @@ plotit(wordlist *wl, char *hcopy, char *devname) ; lv = dv; } - free_pnode(names); d->v_link2 = NULL; /* Now check for 0-length vectors. */ @@ -583,7 +588,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) if (!d->v_length) { fprintf(cp_err, "Error: %s: no such vector\n", d->v_name); - return (FALSE); + goto quit; } /* If there are higher dimensional vectors, transform them into a @@ -658,7 +663,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) oneval ? 1 : 0) { fprintf(cp_err, "Error: plot must be either all pole-zero or contain no poles or zeros\n"); - return (FALSE); + goto quit; } if ((gtype == GRID_POLAR) || (gtype == GRID_SMITH @@ -840,13 +845,13 @@ plotit(wordlist *wl, char *hcopy, char *devname) (gtype == GRID_LOGLOG))) { fprintf(cp_err, "Error: X values must be > 0 for log scale\n"); - return (FALSE); + goto quit; } if ((ylims[0] <= 0.0) && ((gtype == GRID_YLOG) || (gtype == GRID_LOGLOG))) { fprintf(cp_err, "Error: Y values must be > 0 for log scale\n"); - return (FALSE); + goto quit; } /* Fix the plot limits for smith and polar grids. */ @@ -907,7 +912,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) newscale, newlen, 1)) { fprintf(cp_err, "Error: can't interpolate %s\n", v->v_name); - return(FALSE); + goto quit; } tfree(v->v_realdata); @@ -925,7 +930,8 @@ plotit(wordlist *wl, char *hcopy, char *devname) ((gtype == GRID_XLOG) || (gtype == GRID_LOGLOG)), ((gtype == GRID_YLOG) || (gtype == GRID_LOGLOG)), nointerp); - return (TRUE); + rtn = TRUE; + goto quit; } /* See if there is one type we can give for the y scale... */ @@ -942,7 +948,8 @@ plotit(wordlist *wl, char *hcopy, char *devname) xlabel ? xlabel : ft_typabbrev(vecs->v_scale->v_type), ylabel ? ylabel : ft_typabbrev(j), gtype, ptype, vecs); - return (TRUE); + rtn = TRUE; + goto quit; } #ifdef TCL_MODULE @@ -951,7 +958,8 @@ plotit(wordlist *wl, char *hcopy, char *devname) for (d = vecs; d; d = d->v_link2) { blt_plot(d, oneval ? (struct dvec *) NULL : d->v_scale); } - return (TRUE); + rtn = TRUE; + goto quit; } #endif @@ -968,7 +976,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) title ? title : vecs->v_plot->pl_title, hcopy, i, xdelta ? *xdelta : 0.0, ydelta ? *ydelta : 0.0, gtype, ptype, xlabel, ylabel, xt, j, pname, cline)) - return (FALSE); + goto quit; /* Now plot all the graphs. */ for (d = vecs; d; d = d->v_link2) @@ -976,6 +984,10 @@ plotit(wordlist *wl, char *hcopy, char *devname) gr_clean(); - return (TRUE); + rtn = TRUE; +quit: + free_pnode(names); +quit1: + return rtn; } diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index f645e06bc..faf572f9a 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -267,7 +267,7 @@ doit(struct line *deck) /* Now put the .subckt definition found into sss */ sss->su_def = last->li_next; s = last->li_line; - (void) gettok(&s); + txfree(gettok(&s)); sss->su_name = gettok(&s); sss->su_args = copy(s); /* count the number of args in the .subckt line */ @@ -317,7 +317,7 @@ doit(struct line *deck) for (c = deck; c; c = c->li_next) if (prefix(model, c->li_line)) { s = c->li_line; - (void) gettok(&s); + txfree(gettok(&s)); wl = alloc(struct wordlist); wl->wl_next = modnames; if (modnames) @@ -332,8 +332,9 @@ doit(struct line *deck) gotone = FALSE; for (c = deck, lc = NULL; c; ) { if (ciprefix(invoke, c->li_line)) { /* found reference to .subckt (i.e. component with refdes X) */ - gotone = TRUE; - t = s = copy(c->li_line); /* s & t hold copy of component line */ + char *tofree; + gotone = TRUE; + t = tofree = s = copy(c->li_line); /* s & t hold copy of component line */ /* make scname point to first non-whitepace chars after refdes invocation * e.g. if invocation is Xreference, *scname = reference @@ -390,7 +391,7 @@ doit(struct line *deck) devmodtranslate(lcc, scname); s = sss->su_args; - (void) gettok(&t); /* Throw out the subcircuit refdes */ + txfree(gettok(&t)); /* Throw out the subcircuit refdes */ /* now invoke translate, which handles the remainder of the * translation. @@ -408,6 +409,7 @@ doit(struct line *deck) lcc->li_next = c->li_next; c = lcc->li_next; lc = lcc; + tfree(tofree); } /* if (ciprefix(invoke, c->li_line)) . . . */ else { lc = c; @@ -477,7 +479,7 @@ static int translate(struct line *deck, char *formal, char *actual, char *scname, char *subname) { struct line *c; - char *buffer, *next_name, dev_type, *name, *s, *t, ch; + char *buffer, *next_name, dev_type, *name, *s, *t, ch, *nametofree; int nnodes, i, dim; /* settrans builds the table holding the translated netnames. */ @@ -695,8 +697,10 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub return 0; } - dim = (int *) atoi( (char *)gettok_noparens(&s) ); /* convert returned string to int */ - + nametofree = gettok_noparens(&s); + dim = atoi(nametofree); /* convert returned string to int */ + tfree(nametofree); + /* move pointer ahead of ) */ if( get_r_paren(&s) == 1 ) { fprintf(cp_err, "Error: no right paren after POLY %s\n", @@ -782,7 +786,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub /*================= Default case ===================*/ default: /* this section handles ordinary components */ s = c->li_line; - name = gettok(&s); + nametofree = name = gettok(&s); if (!name) continue; if (!*name) { @@ -804,7 +808,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub name); else (void) sprintf(buffer, "%c:%s ", ch, scname); - + tfree(nametofree); /* Next iterate over all nodes (netnames) found and translate them. */ @@ -830,6 +834,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub (void) sprintf(buffer + strlen(buffer), "%s:%s ", scname, name); } + free(name); } /* while (nnodes-- . . . . */ /* Now translate any devices (i.e. controlling sources). @@ -838,7 +843,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub */ nnodes = numdevs(c->li_line); while (nnodes-- > 0) { - name = gettok(&s); + t = name = gettok(&s); if (name == NULL) { fprintf(cp_err, "Error: too few devs: %s\n", c->li_line); @@ -855,7 +860,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub else (void) sprintf(buffer + strlen(buffer), "%c:%s ", ch, scname); - + tfree(t); } /* while (nnodes--. . . . */ @@ -1100,13 +1105,14 @@ numnodes(char *name) i = 0; s = buf; gotit = 0; - t = gettok(&s); /* Skip component name */ + txfree(gettok(&s)); /* Skip component name */ while ((i < n) && (*s) && !gotit) { t = gettok(&s); for (wl = modnames; wl; wl = wl->wl_next) if (eq(t, wl->wl_word)) gotit = 1; i++; + tfree(t); } /* while . . . . */ /* Note: node checks must be done on #_of_node-1 because the */ @@ -1125,7 +1131,7 @@ numnodes(char *name) return (n); for (s = buf, i = 0; *s && (i < 4); i++) - (void) gettok(&s); + txfree(gettok(&s)); if (i == 3) return (3); @@ -1138,8 +1144,11 @@ numnodes(char *name) /* Now, is this a model? */ t = gettok(&s); for (wl = modnames; wl; wl = wl->wl_next) - if (eq(t, wl->wl_word)) + if (eq(t, wl->wl_word)) { + tfree(t); return (3); + } + tfree(t); return (4); } @@ -1221,7 +1230,7 @@ modtranslate(struct line *deck, char *subname) tfree(c->li_line); c->li_line = buffer; t = c->li_line; - (void) gettok(&t); + txfree(gettok(&t)); wl = alloc(struct wordlist); wl->wl_next = modnames; if (modnames) diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index e30967600..f16341f4a 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -600,8 +600,7 @@ vec_free(struct dvec *v) pl = v->v_plot; /* Now we have to take this dvec out of the plot list. */ - if (pl == NULL) - fprintf(cp_err, "vec_free: Internal Error: plot ptr is 0\n"); + if (pl != NULL) { if (pl->pl_dvecs == v) pl->pl_dvecs = v->v_next; else { @@ -620,12 +619,15 @@ vec_free(struct dvec *v) else pl->pl_scale = NULL; } + } tfree(v->v_name); + if(v->v_length) { if (isreal(v)) { tfree(v->v_realdata); } else { tfree(v->v_compdata); } + } tfree(v); return; } diff --git a/src/include/ngspice.h b/src/include/ngspice.h index b76a0f779..268cfc4df 100644 --- a/src/include/ngspice.h +++ b/src/include/ngspice.h @@ -116,6 +116,9 @@ struct timeb timebegin; #endif extern char *gettok(char **s); +extern char *gettok_noparens(char **s); +extern int get_l_paren(char **s); +extern int get_r_paren(char **s); extern void appendc(char *s, char c); extern int scannum(char *str); extern int ciprefix(register char *p, register char *s); diff --git a/src/spicelib/parser/inp2dot.c b/src/spicelib/parser/inp2dot.c index 58f88e7bd..a47287a90 100644 --- a/src/spicelib/parser/inp2dot.c +++ b/src/spicelib/parser/inp2dot.c @@ -640,74 +640,89 @@ INP2dot(void *ckt, INPtables *tab, card *current, void *task, void *gnode) void *foo = NULL; /* pointer to analysis */ /* the part of the current line left to parse */ char *line = current->line; - + int rtn = 0; + INPgetTok(&line, &token, 1); if (strcmp(token, ".model") == 0) { /* don't have to do anything, since models were all done in * pass 1 */ - return (0); + goto quit; } else if ((strcmp(token, ".width") == 0) || strcmp(token, ".print") == 0 || strcmp(token, ".plot") == 0) { /* obsolete - ignore */ LITERR(" Warning: obsolete control card - ignored \n"); - return (0); + goto quit; } else if ((strcmp(token, ".temp") == 0)) { /* .temp temp1 temp2 temp3 temp4 ..... */ /* not yet implemented - warn & ignore */ LITERR(" Warning: .TEMP card obsolete - use .options TEMP and TNOM\n"); - return (0); + goto quit; } else if ((strcmp(token, ".op") == 0)) { - return dot_op(line, ckt, tab, current, task, gnode, foo); + rtn = dot_op(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".nodeset") == 0)) { - return(0); + goto quit; } else if ((strcmp(token, ".disto") == 0)) { - return dot_disto(line, ckt, tab, current, task, gnode, foo); + rtn = dot_disto(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".noise") == 0)) { - return dot_noise(line, ckt, tab, current, task, gnode, foo); + rtn = dot_noise(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".four") == 0) || (strcmp(token, ".fourier") == 0)) { /* .four */ /* not implemented - warn & ignore */ LITERR("Use fourier command to obtain fourier analysis\n"); - return (0); + goto quit; } else if ((strcmp(token, ".ic") == 0)) { - return (0); + goto quit; } else if ((strcmp(token, ".ac") == 0)) { - return dot_ac(line, ckt, tab, current, task, gnode, foo); + rtn = dot_ac(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".pz") == 0)) { - return dot_pz(line, ckt, tab, current, task, gnode, foo); + rtn = dot_pz(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".dc") == 0)) { - return dot_dc(line, ckt, tab, current, task, gnode, foo); + rtn = dot_dc(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".tf") == 0)) { - return dot_tf(line, ckt, tab, current, task, gnode, foo); + rtn = dot_tf(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".tran") == 0)) { - return dot_tran(line, ckt, tab, current, task, gnode, foo); + rtn = dot_tran(line, ckt, tab, current, task, gnode, foo); + goto quit; } else if ((strcmp(token, ".subckt") == 0) || (strcmp(token, ".ends") == 0)) { /* not yet implemented - warn & ignore */ LITERR(" Warning: Subcircuits not yet implemented - ignored \n"); - return (0); + goto quit; } else if ((strcmp(token, ".end") == 0)) { /* .end - end of input */ /* not allowed to pay attention to additional input - return */ - return (1); + rtn = 1; + goto quit; } else if (strcmp(token, ".sens") == 0) { - return dot_sens(line, ckt, tab, current, task, gnode, foo); + rtn = dot_sens(line, ckt, tab, current, task, gnode, foo); + goto quit; } #ifdef WANT_SENSE2 else if ((strcmp(token, ".sens2") == 0)) { - return dot_sens2(line, ckt, tab, current, task, gnode, foo); + rtn = dot_sens2(line, ckt, tab, current, task, gnode, foo); + goto quit; } #endif else if ((strcmp(token, ".probe") == 0)) { /* Maybe generate a "probe" format file in the future. */ - return 0; + goto quit; } else if ((strcmp(token, ".options") == 0)|| (strcmp(token,".option")==0) || (strcmp(token,".opt")==0)) { - return dot_options(line, ckt, tab, current, task, gnode, foo); + rtn = dot_options(line, ckt, tab, current, task, gnode, foo); + goto quit; } LITERR(" unimplemented control card - error \n"); - return (0); +quit: + tfree(token); + return rtn; } diff --git a/src/spicelib/parser/inp2r.c b/src/spicelib/parser/inp2r.c index 3b7c35140..fe9a686d0 100644 --- a/src/spicelib/parser/inp2r.c +++ b/src/spicelib/parser/inp2r.c @@ -79,6 +79,7 @@ void INP2R(void *ckt, INPtables * tab, card * current) type = thismodel->INPmodType; } } else { + tfree(model); /* It is not a model */ line = saveline; /* go back */ type = mytype; @@ -91,6 +92,7 @@ void INP2R(void *ckt, INPtables * tab, card * current) } IFC(newInstance, (ckt, mdfast, &fast, name)); } else { + tfree(model); /* The token is null and a default model will be created */ type = mytype; if (!tab->defRmod) { diff --git a/src/spicelib/parser/inpdomod.c b/src/spicelib/parser/inpdomod.c index 2e14a4557..d6415dae1 100644 --- a/src/spicelib/parser/inpdomod.c +++ b/src/spicelib/parser/inpdomod.c @@ -34,6 +34,7 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) #endif INPgetTok(&line, &modname, 1); /* throw away '.model' */ + tfree(modname); INPgetTok(&line, &modname, 1); /* get model name */ INPinsert(&modname, tab); /* stick model name into table */ INPgetTok(&line, &typename, 1); /* get model type */ @@ -530,5 +531,6 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) #endif } + tfree(typename); return (err); } diff --git a/src/spicelib/parser/inpdpar.c b/src/spicelib/parser/inpdpar.c index 1b6d0cf35..37a723fc4 100644 --- a/src/spicelib/parser/inpdpar.c +++ b/src/spicelib/parser/inpdpar.c @@ -30,10 +30,11 @@ char *INPdevParse(char **line, void *ckt, int dev, void *fast, /* flag - 1 if leading double given, 0 otherwise */ { int error; /* int to store evaluate error return codes in */ - char *parm; + char *parm=NULL; char *errbuf; int i; IFvalue *val; + char *rtn=NULL; /* check for leading value */ *waslead = 0; @@ -44,10 +45,14 @@ char *INPdevParse(char **line, void *ckt, int dev, void *fast, *leading = 0.0; while (**line != (char) 0) { error = INPgetTok(line, &parm, 1); - if (!*parm) + if (!*parm) { + FREE(parm); continue; - if (error) - return (INPerror(error)); + } + if (error) { + rtn = (INPerror(error)); + goto quit; + } for (i = 0; i < (*(*(ft_sim->devices)[dev]).numInstanceParms); i++) { if (strcmp(parm, ((*(ft_sim->devices)[dev]).instanceParms[i]. @@ -56,25 +61,32 @@ char *INPdevParse(char **line, void *ckt, int dev, void *fast, INPgetValue(ckt, line, ((*(ft_sim->devices)[dev]). instanceParms[i].dataType), tab); - if (!val) - return (INPerror(E_PARMVAL)); + if (!val) { + rtn = (INPerror(E_PARMVAL)); + goto quit; + } error = (*(ft_sim->setInstanceParm)) (ckt, fast, (*(ft_sim->devices) [dev]). instanceParms[i].id, val, (IFvalue *) NULL); - if (error) - return (INPerror(error)); + if (error) { + rtn = (INPerror(error)); + goto quit; + } break; } } if (i == (*(*(ft_sim->devices)[dev]).numInstanceParms)) { errbuf = MALLOC(strlen(parm) + 25); (void) sprintf(errbuf, " unknown parameter (%s) \n", parm); - return (errbuf); + rtn = (errbuf); + goto quit; } FREE(parm); } - return ((char *) NULL); +quit: + FREE(parm); + return rtn; } diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index 74bb33761..0a52a28c7 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -74,7 +74,9 @@ char *INPgetMod(void *ckt, char *name, INPmodel ** model, INPtables * tab) INPgetTok(&line, &parm, 1); /* throw away '.model' */ + tfree(parm); INPgetTok(&line, &parm, 1); /* throw away 'modname' */ + tfree(parm); while (*line != 0) { INPgetTok(&line, &parm, 1); if (!*parm) diff --git a/src/spicelib/parser/inppas3.c b/src/spicelib/parser/inppas3.c index 3f04dbaa8..9afab1f41 100644 --- a/src/spicelib/parser/inppas3.c +++ b/src/spicelib/parser/inppas3.c @@ -30,7 +30,7 @@ INPpas3(void *ckt, card *data, INPtables *tab, void *task, char *line; /* the part of the current line left to parse */ char *name; /* the node's name */ - char *token; /* a token from the line */ + char *token=NULL; /* a token from the line */ IFparm *prm; /* pointer to parameter to search through array */ IFvalue ptemp; /* a value structure to package @@ -46,6 +46,7 @@ INPpas3(void *ckt, card *data, INPtables *tab, void *task, for(current = data; current != NULL; current = current->nextcard) { line = current->line; + FREE(token) INPgetTok(&line,&token,1); if (strcmp(token,".nodeset")==0) { @@ -60,7 +61,7 @@ INPpas3(void *ckt, card *data, INPtables *tab, void *task, if(which == -1) { LITERR("nodeset unknown to simulator. \n") - return; + goto quit; } for(;;) { @@ -95,7 +96,7 @@ INPpas3(void *ckt, card *data, INPtables *tab, void *task, if(which==-1) { LITERR("ic unknown to simulator. \n") - return; + goto quit; } for(;;) { @@ -119,6 +120,8 @@ INPpas3(void *ckt, card *data, INPtables *tab, void *task, } } } - return; +quit: + FREE(token); + return; }