chiark / gitweb /
clean up a few leaks
authorian <ian>
Sat, 26 Apr 2008 22:59:21 +0000 (22:59 +0000)
committerian <ian>
Sat, 26 Apr 2008 22:59:21 +0000 (22:59 +0000)
hostside/record-i.h
hostside/record.c

index 8d90c395299af22390846814b2db4885309574cf..81b04f9507fcb6b7870c2395aec6ede518e30319 100644 (file)
@@ -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*/
index ab504e4c91b47c4ddbe77b034ee4723c7fdd2c59..18d4cbb2916a37f85b8544053cf1b1b9777a230c 100644 (file)
@@ -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();
 }