From: ian Date: Sat, 26 Apr 2008 22:59:21 +0000 (+0000) Subject: clean up a few leaks X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=b745bc3b15403a1ba379f9dd2e776ef99e2c41b5;p=trains.git clean up a few leaks --- diff --git a/hostside/record-i.h b/hostside/record-i.h index 8d90c39..81b04f9 100644 --- a/hostside/record-i.h +++ b/hostside/record-i.h @@ -27,6 +27,7 @@ void record_tempzone_clear(void); int record_yyparse(void); int record_yylex(void); +int record_yylex_destroy(void); extern int record_yylineno; #endif /*RECORD_I_H*/ diff --git a/hostside/record.c b/hostside/record.c index ab504e4..18d4cbb 100644 --- a/hostside/record.c +++ b/hostside/record.c @@ -170,6 +170,14 @@ void record_tempzone_clear(void) { tempzone_ptr= tempzones_head->buf; } +static void record_tempzone_freeall(void) { + record_tempzone_clear(); + free(tempzones_head); + tempzones_head= 0; + tempzone_ptr= 0; + tempzone_remain= tempzone_head_len= 0; +} + /*---------- semantic actions ----------*/ /* * These are all called only during the second pass, when trains is non-0. @@ -437,6 +445,7 @@ static void parse_file(const char *why) { record_yylineno= 0; r= record_yyparse(); assert(!r); /* we're supposed to call yyerror which dies */ + fclose(f); } static void parse_pass(const char **argv) { @@ -454,4 +463,6 @@ void records_parse(const char **argv) { parse_pass(argv); /* trains!=0: populates data area */ record_tempzone_clear(); speeds_postprocess(); + record_tempzone_freeall(); + record_yylex_destroy(); }