From 3375e1b976cd3787cdb136ec210131070df2ebfa Mon Sep 17 00:00:00 2001 From: Michael Woodworth Date: Thu, 5 Apr 2012 19:03:25 +0200 Subject: [PATCH] fix a memory leak in parse_line() This has a HUGE affect on memory usage --- src/spicelib/parser/inpgmod.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index a8805a38e..8f96ae1a5 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/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,12 +157,13 @@ 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++ ) @@ -170,6 +171,7 @@ parse_line( char* line, char* tokens[], int num_tokens, double values[], bool fo flag = FALSE; break; } + return flag; }