remove memory leaks

This commit is contained in:
h_vogt 2012-08-04 19:09:13 +02:00
parent 2516a118a3
commit acfc7a2a27
6 changed files with 25 additions and 6 deletions

View File

@ -2996,7 +2996,7 @@ inp_fix_param_values( struct line *deck )
{
struct line *c = deck;
char *line, *beg_of_str, *end_of_str, *old_str, *equal_ptr, *new_str;
char *vec_str, *natok, *buffer, *newvec, *whereisgt;
char *vec_str, *tmp_str, *natok, *buffer, *newvec, *whereisgt;
bool control_section = FALSE;
wordlist *nwl;
int parens;
@ -3098,7 +3098,7 @@ inp_fix_param_values( struct line *deck )
while (*end_of_str != ']')
end_of_str++;
/* string xx yyy from vector [xx yyy] */
vec_str = copy_substring(beg_of_str + 1, end_of_str);
tmp_str = vec_str = copy_substring(beg_of_str + 1, end_of_str);
/* work on vector elements inside [] */
nwl = NULL;
@ -3140,6 +3140,7 @@ inp_fix_param_values( struct line *deck )
nwl = wl_cons(copy(buffer), nwl);
tfree(buffer);
}
tfree(tmp_str);
nwl = wl_reverse(nwl);
/* new vector elements */
newvec = wl_flatten(nwl);

View File

@ -897,6 +897,11 @@ plotit(wordlist *wl, char *hcopy, char *devname)
ylims[1] = 1.0;
}
if(xlim)
tfree(xlim);
if(ylim)
tfree(ylim);
/* We don't want to try to deal with smith plots for asciiplot. */
if (devname && eq(devname, "lpr")) {
/* check if we should (can) linearize */

View File

@ -978,6 +978,8 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub
for (;;) {
/* rotate the tokens and get the the next one */
if (name)
tfree(name);
name = next_name;
next_name = MIFgettok(&s);

View File

@ -163,6 +163,7 @@ card *current ) /* the card we are to parse */
char *def_port_type_str; /* The default port type in string form */
char *next_token; /* a token string */
char *tmp_token; /* a token string */
int i; /* a loop counter */
int j; /* a loop counter */
@ -195,8 +196,11 @@ card *current ) /* the card we are to parse */
INPinsert(&name, tab);
/* locate the last token on the line (i.e. model name) and put it into "model" */
while(*line != '\0')
while(*line != '\0') {
if (model)
tfree(model);
model = MIFgettok(&line);
}
/* make sure the model name was there. */
if(model == NULL) {
@ -212,7 +216,6 @@ card *current ) /* the card we are to parse */
return;
}
/* get the integer index into the DEVices data array for this */
/* model */
type = thismodel->INPmodType;
@ -237,7 +240,8 @@ card *current ) /* the card we are to parse */
/* reset 'line', and then read instance name again. */
line = current->line;
MIFgettok(&line); /* read instance name again . . . .*/
tmp_token = MIFgettok(&line); /* read instance name again . . . .*/
tfree(tmp_token);
/* OK -- now &line points to the first token after
the instance name and we are ready to process the connections
@ -469,6 +473,8 @@ card *current ) /* the card we are to parse */
return;
}
tfree(model);
/* check connection constraints */
for(i = 0; i < DEVices[type]->DEVpublic.num_conn; i++) {

View File

@ -181,11 +181,14 @@ char *MIFgetMod(
/* parameter isolation, identification, binding */
line = modtmp->INPmodLine->line;
INPgetTok(&line,&parm,1); /* throw away '.model' */
tfree(parm);
INPgetTok(&line,&parm,1); /* throw away 'modname' */
tfree(parm);
/* throw away the modtype - we don't treat it as a parameter */
/* like SPICE does */
INPgetTok(&line,&parm,1); /* throw away 'modtype' */
tfree(parm);
while(*line != 0) {
INPgetTok(&line,&parm,1);

View File

@ -220,9 +220,11 @@ MIFgetValue (
if(! is_array)
break;
tfree(token);
} /* end forever loop */
tfree(token);
return(&val);
}