diff --git a/ChangeLog b/ChangeLog index b6cb392c5..e1dc7d4e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ plotit.c, inpgtok.c: some more memory leaks removed spicenum.c: release of memory for dico->dyncategory corrected + subckt.c, inp.c, inpcom.c more on memory leaks 2009-04-01 Dietmar Warning * frontend/resource.c, misc/misc_time.c: init of rusage structure to prevent diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 4dd302c89..6c0f8ac09 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -55,7 +55,8 @@ $Id$ /* static declarations */ static char * upper(register char *string); static bool doedit(char *filename); -static void line_free_x(struct line * deck, bool recurse); + +void line_free_x(struct line * deck, bool recurse); /* uncomment this line for getting deck output after all @@ -302,7 +303,7 @@ top2: * All lines linked via the li_actual field are always recursivly freed. * SJB - 22nd May 2001 */ -static void +void line_free_x(struct line * deck, bool recurse) { if(!deck) return; @@ -394,7 +395,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename) cp_evloop(dd->li_line); } } + /* free the control deck */ line_free(deck,TRUE); +/* printf("Command deck freed\n"); */ } /* end if(comfile) */ else { /* must be regular deck . . . . */ @@ -614,7 +617,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename) } #endif - line_free(deck, TRUE); + /* line_free(deck, TRUE); // have to keep this to allow listing + printf("Real deck freed\n"); */ /* Now that the deck is loaded, do the commands, if there are any */ if (controls) { diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 136ed52f0..d95e0ac28 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -1119,11 +1119,10 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name) s = copys; /* reuse s, but remember, buffer still points to allocated memory */ } } - - /* lower case the file name for later string compares */ - s_ptr = strdup(s); - s_lower = strdup(s); - for(s_ptr = s_lower; *s_ptr && (*s_ptr != '\n'); s_ptr++) *s_ptr = tolower(*s_ptr); + /* lower case the file name for later string compares */ +/* s_ptr = strdup(s); */ + s_lower = strdup(s); + for(s_ptr = s_lower; *s_ptr && (*s_ptr != '\n'); s_ptr++) *s_ptr = tolower(*s_ptr); found_library = FALSE; for ( i = 0; i < num_libraries; i++ ) { diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 8d3c1fb5d..3e2c30ac2 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -63,6 +63,9 @@ $Id$ #include "numparam/numpaif.h" +extern void line_free_x(struct line * deck, bool recurse); +#define line_free(line,flag) { line_free_x(line,flag); line = NULL; } + /* ----- static declarations ----- */ static struct line * doit(struct line *deck); static int translate(struct line *deck, char *formal, char *actual, char *scname, @@ -365,7 +368,7 @@ doit(struct line *deck) { struct line *c, *last, *lc, *lcc; struct line *savenext; - struct subs *sss = (struct subs *) NULL, *ks; /* *sss and *ks temporarily hold decks to substitute */ + struct subs *sssfree, *sss = (struct subs *) NULL, *ks; /* *sss and *ks temporarily hold decks to substitute */ char *s, *t, *scname, *subname; int nest, numpasses = MAXNEST, i; bool gotone; @@ -427,7 +430,7 @@ doit(struct line *deck) } - sss = alloc(struct subs); + sssfree = sss = alloc(struct subs); if (!lcc) /* if lcc is null, then no .ends was found. */ lcc = last; if ( use_numparams==FALSE ) @@ -626,6 +629,23 @@ doit(struct line *deck) subs = ts; modnames = tmodnames; submod = tsubmod; +/* +struct subs { + char *su_name; + char *su_args; + int su_numargs; + struct line *su_def; + struct subs *su_next; +} ; +*/ + while(sssfree) { + struct subs *sss2 = sssfree; + sssfree = sssfree->su_next; + tfree(sss2->su_name); + tfree(sss2->su_args); + line_free(sss2->su_def, TRUE); + tfree(sss2); + } return (deck); }