Permalink
Browse files

fixed a memory leak in the parcing of lines

This has a HUGE affect on memory usage
  • Loading branch information...
1 parent 68cd5fe commit 3775b1d80cd4284a62c78a6fe0702068233f1c46 Michael Woodworth committed with rlar Apr 5, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/spicelib/parser/inpgmod.c
View
8 src/spicelib/parser/inpgmod.c
@@ -141,7 +141,7 @@ create_model( CKTcircuit* ckt, INPmodel* modtmp, INPtables* tab )
static bool
parse_line( char* line, char* tokens[], int num_tokens, double values[], bool found[] )
{
- char* token;
+ char* token = NULL;
int get_index = -1;
int i;
bool flag = TRUE;
@@ -157,19 +157,21 @@ parse_line( char* line, char* tokens[], int num_tokens, double values[], bool fo
found[get_index] = TRUE;
get_index = -1;
continue;
- } else {
- INPgetNetTok( &line, &token, 1 );
}
+ INPgetNetTok( &line, &token, 1 );
+
for ( i = 0; i < num_tokens; i++ )
if ( strcmp( tokens[i], token ) == 0 ) get_index = i;
+ txfree(token);
}
for ( i = 0; i < num_tokens; i++ )
if ( found[i] == FALSE ) {
flag = FALSE;
break;
}
+
return flag;
}

0 comments on commit 3775b1d

Please sign in to comment.