diff --git a/ChangeLog b/ChangeLog index 9d4d6bebe..b6cb392c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ 2009-04-05 Holger Vogt * com_fft.c, inpcom.c, variable.c, variable.h, resource.c, cpitf.c, - plotit.c: + plotit.c, inpgtok.c: some more memory leaks removed + spicenum.c: release of memory for dico->dyncategory corrected 2009-04-01 Dietmar Warning * frontend/resource.c, misc/misc_time.c: init of rusage structure to prevent diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index 45f87ce71..22d7d7003 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -212,7 +212,6 @@ static void modernizeex (char *s) /* old style expressions &(..) and &id --> new style with braces. */ { -// Strbig (Llen, t); int i, state, ls; char c, d; Strbig (dynLlen, t); @@ -290,7 +289,6 @@ transform (tdico * dico, char *s, unsigned char nostripping, char *u) * 'B' netlist (or .model ?) line that had Braces killed */ { -// Strbig (Llen, t); char category; int i, k, a, n; Strbig (dynLlen, t); @@ -389,7 +387,6 @@ static tdico *dico = NULL; static void putlogfile (char c, int num, char *t) { -// Strbig (Llen, u); Str (20, fname); Strbig (dynLlen, u); if (dologfile) @@ -439,8 +436,6 @@ nupa_init (char *srcfile) dico->dyncategory[i] = '?'; } -// sini (dico->srcfile, sizeof (dico->srcfile) - 4); - if (srcfile != NULL) scopy (dico->srcfile, srcfile); } @@ -462,8 +457,9 @@ nupa_done (void) for (i = dynmaxline ; i >= 0; i--) { dispose ((void *) dico->dynrefptr[i]); - dispose ((void *) dico->dyncategory[i]); } + dispose ((void *) dico->dynrefptr); + dispose ((void *) dico->dyncategory); dispose ((void *) dico); dico = NULL; dispose ((void *) inst_dico); @@ -622,8 +618,6 @@ nupa_copy (char *s, int linenum) - substitute placeholders for all {..} --> 10-digit numeric values. */ { -// Strbig (Llen, u); -// Strbig (Llen, keywd); char *t; int ls; char c, d; diff --git a/src/spicelib/parser/inpgtok.c b/src/spicelib/parser/inpgtok.c index 17ec5f3d0..fc5b2e7da 100644 --- a/src/spicelib/parser/inpgtok.c +++ b/src/spicelib/parser/inpgtok.c @@ -27,6 +27,7 @@ int INPgetTok(char **line, char **token, int gobble) { char *point; int signstate; + int diffpoints; /* scan along throwing away garbage characters until end of line or a separation char is found */ @@ -94,7 +95,17 @@ int INPgetTok(char **line, char **token, int gobble) } - if (point == *line && *point) /* Weird items, 1 char */ + diffpoints = point - *line; + if ((diffpoints < 1) && *point) + diffpoints = 1; /* Weird items, 1 char */ + *token = (char *) tmalloc((1 + diffpoints)*sizeof(char)); + if (!*token) + return (E_NOMEM); + (void) strncpy(*token, *line, diffpoints); + *(*token + diffpoints) = '\0'; + *line = point; +/* + if (point == *line && *point) point++; *token = (char *) MALLOC(1 + point - *line); if (!*token) @@ -102,7 +113,7 @@ int INPgetTok(char **line, char **token, int gobble) (void) strncpy(*token, *line, point - *line); *(*token + (point - *line)) = '\0'; *line = point; - + */ /* gobble garbage to next token */ for (; **line != '\0'; (*line)++) { if (**line == ' ') @@ -139,6 +150,7 @@ int INPgetNetTok(char **line, char **token, int gobble) { char *point; int signstate; + int diffpoints; /* scan along throwing away garbage characters until end of line or a separation char is found */ @@ -181,7 +193,18 @@ int INPgetNetTok(char **line, char **token, int gobble) } /* now copy found token into *token */ - if (point == *line && *point) /* Weird items, 1 char */ + diffpoints = point - *line; + if ((diffpoints < 1) && *point) + diffpoints = 1; /* Weird items, 1 char */ + *token = (char *) tmalloc((1 + diffpoints)*sizeof(char)); + if (!*token) + return (E_NOMEM); + (void) strncpy(*token, *line, diffpoints); + *(*token + diffpoints) = '\0'; + *line = point; + +/* + if (point == *line && *point) point++; *token = (char *) MALLOC(1 + point - *line); if (!*token) @@ -189,7 +212,7 @@ int INPgetNetTok(char **line, char **token, int gobble) (void) strncpy(*token, *line, point - *line); *(*token + (point - *line)) = '\0'; *line = point; - +*/ /* gobble garbage to next token */ for (; **line != '\0'; (*line)++) { if (**line == ' ')