Modified Files:

Tag: TCLSPICE
 	ChangeLog src/frontend/com_let.c
 	src/frontend/com_set.c src/frontend/evaluate.c
 	src/frontend/parse.c src/frontend/variable.c
 	src/frontend/parser/complete.c

	Plug memory leaks
This commit is contained in:
stefanjones 2003-07-15 12:16:25 +00:00
parent 3a100bdc64
commit b9377782d3
7 changed files with 39 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2003-07-15 Stefan Jones <stefan.jones@multigig.com>
* /src/frontend/{com_let.c,com_set.c,evaluate.c,parse.c,variable.c}
src/frontend/parser/complete.c :
Memory leaks plugged
2003-07-14 Stefan Jones <stefan.jones@multigig.com>
* src/include/enh.h src/spicelib/analysis/{acan.c,cktload.c,cktsetup.c,cktsopt.c}

View File

@ -101,6 +101,7 @@ com_let(wordlist *wl)
if (!t) {
fprintf(cp_err, "Error: Can't evaluate %s\n", rhs);
tfree(p);
free_pnode(nn);
return;
}
@ -117,6 +118,7 @@ com_let(wordlist *wl)
if (numdims) {
fprintf(cp_err, "Can't assign into a subindex of a new vector\n");
tfree(p);
free_pnode(nn);
return;
}
@ -176,6 +178,7 @@ com_let(wordlist *wl)
if (newvec)
n->v_flags &= ~VF_PERMANENT;
tfree(p);
free_pnode(nn);
return;
}
if (isreal(t) != isreal(n)) {
@ -184,6 +187,7 @@ com_let(wordlist *wl)
if (newvec)
n->v_flags &= ~VF_PERMANENT;
tfree(p);
free_pnode(nn);
return;
} else if (isreal(t)) {
bcopy((char *) t->v_realdata, (char *) (n->v_realdata + offset),
@ -201,7 +205,7 @@ com_let(wordlist *wl)
if (newvec)
cp_addkword(CT_VECTOR, n->v_name);
/* XXXX Free t !?! */
tfree(p);
free_pnode(nn);
return;
}

View File

@ -13,7 +13,7 @@
void
com_set(wordlist *wl)
{
struct variable *vars;
struct variable *vars, *tmp;
char *s;
if (wl == NULL) {
@ -44,8 +44,14 @@ com_set(wordlist *wl)
s = (char *) NULL;
}
cp_vset(vars->va_name, vars->va_type, s);
if(vars->va_type == VT_STRING)
tfree(s);
tfree(vars->va_name);
tmp = vars;
vars = vars->va_next;
tfree(tmp);
}
return;
}

View File

@ -67,8 +67,11 @@ ft_evaluate(struct pnode *node)
return NULL;
}
if (node->pn_name && !ft_evdb && d && !d->v_link2)
if (node->pn_name && !ft_evdb && d && !d->v_link2) {
if(d->v_name)
tfree(d->v_name);
d->v_name = copy(node->pn_name);
}
if (!d->v_length) {
fprintf(cp_err, "Error: no such vector %s\n", d->v_name);

View File

@ -405,13 +405,16 @@ static struct pnode *
parse(void)
{
struct element stack[STACKSIZE];
int sp = 0, st, i;
char *stringStack[STACKSIZE];
int sp = 0, st, i, fsp = 0;
struct element *top, *next;
struct pnode *pn, *lpn, *rpn;
char rel;
stack[0].e_token = END;
next = lexer();
if(next->e_token == VALUE && next->e_type == STRING)
stringStack[fsp++] = next->e_string;
while ((sp > 1) || (next->e_token != END)) {
/* Find the top-most terminal. */
@ -424,13 +427,15 @@ parse(void)
case L:
case E:
/* Push the token read. */
if (sp == (STACKSIZE - 1)) {
if (sp == (STACKSIZE - 1) || fsp == (STACKSIZE-1)) {
fprintf(cp_err, "Error: stack overflow\n");
return (NULL);
}
bcopy((char *) next, (char *) &stack[++sp],
sizeof (struct element));
next = lexer();
if(next->e_token == VALUE && next->e_type == STRING)
stringStack[fsp++] = next->e_string;
continue;
case R:
@ -506,6 +511,8 @@ parse(void)
}
}
pn = makepnode(&stack[1]);
for(i=0;i<fsp;i++)
tfree(stringStack[i]);
if (pn)
return (pn);
err:
@ -815,6 +822,9 @@ free_pnode(struct pnode *t)
free_pnode(t->pn_left);
free_pnode(t->pn_right);
free_pnode(t->pn_next);
tfree(t->pn_name);
if(t->pn_value)
vec_free(t->pn_value);
tfree(t);
}

View File

@ -518,7 +518,6 @@ cp_addkword(int class, char *word)
class);
return;
}
word = copy(word);
cc = clookup(word, &keywords[class], FALSE, TRUE);
cc->cc_invalid = 0;
return;

View File

@ -238,13 +238,15 @@ cp_vset(char *varname, char type, char *value)
struct variable *
cp_setparse(wordlist *wl)
{
char *name, *val, *copyval, *s, *ss;
char *name=NULL, *val, *copyval, *s, *ss;
double *td;
struct variable *listv = NULL, *vv, *lv = NULL;
struct variable *vars = NULL;
int balance;
while (wl) {
if(name)
tfree(name);
name = cp_unquote(wl->wl_word);
wl = wl->wl_next;
if (((wl == NULL) || (*wl->wl_word != '=')) &&
@ -357,6 +359,8 @@ cp_setparse(wordlist *wl)
}
tfree(copyval);/*DG: must free ss any way to avoid cp_unquote memory leak */
}
if(name)
tfree(name);
return (vars);
}