diff main.c @ 135:eaae8014a94a

Don't assert and leak memory if failing during argument collection. Once you have a -D option or a -include foo option, you need to clean up the arrays those are accumulated in if you die before they're collected and handled.
author David A. Holland
date Tue, 09 Jul 2013 13:35:40 -0400
parents 64c4de3709de
children 59680a727e9d
line wrap: on
line diff
--- a/main.c	Sun Jun 16 22:41:27 2013 -0400
+++ b/main.c	Tue Jul 09 13:35:40 2013 -0400
@@ -108,6 +108,16 @@
 void
 commandline_macros_cleanup(void)
 {
+	unsigned i, num;
+	struct commandline_macro *cm;
+
+	num = array_num(&commandline_macros);
+	for (i=0; i<num; i++) {
+		cm = array_get(&commandline_macros, i);
+		dofree(cm, sizeof(*cm));
+	}
+	array_setsize(&commandline_macros, 0);
+	
 	array_cleanup(&commandline_macros);
 }
 
@@ -252,6 +262,16 @@
 void
 commandline_files_cleanup(void)
 {
+	unsigned i, num;
+	struct commandline_file *cf;
+
+	num = array_num(&commandline_files);
+	for (i=0; i<num; i++) {
+		cf = array_get(&commandline_files, i);
+		dofree(cf, sizeof(*cf));
+	}
+	array_setsize(&commandline_files, 0);
+
 	array_cleanup(&commandline_files);
 }