[asterisk-commits] murf: branch murf/bug8684-trunk r81324 - /team/murf/bug8684-trunk/main/config.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 28 18:13:30 CDT 2007


Author: murf
Date: Tue Aug 28 18:13:29 2007
New Revision: 81324

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81324
Log:
OK, this is good. I have nested include files being recreated just fine... more testing tomorrow.

Modified:
    team/murf/bug8684-trunk/main/config.c

Modified: team/murf/bug8684-trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8684-trunk/main/config.c?view=diff&rev=81324&r1=81323&r2=81324
==============================================================================
--- team/murf/bug8684-trunk/main/config.c (original)
+++ team/murf/bug8684-trunk/main/config.c Tue Aug 28 18:13:29 2007
@@ -248,7 +248,7 @@
 	inc = ast_calloc(1,sizeof(struct ast_config_include));
 	inc->include_location_file = ast_strdup(from_file);
 	inc->include_location_lineno = from_lineno;
-	if (inc)
+	if (!ast_strlen_zero(real_included_file_name))
 		inc->included_file = ast_strdup(real_included_file_name);
 	else
 		inc->included_file = ast_strdup(included_file);
@@ -350,7 +350,6 @@
 	if (new) {
 		new->lineno = old->lineno;
 		new->object = old->object;
-		new->file = old->file;
 		new->blanklines = old->blanklines;
 		/* TODO: clone comments? */
 	}
@@ -426,7 +425,26 @@
 void ast_category_destroy(struct ast_category *cat)
 {
 	ast_variables_destroy(cat->root);
+	if (cat->file)
+		free(cat->file);
+	
 	ast_free(cat);
+}
+
+static void ast_includes_destroy(struct ast_config_include *incls)
+{
+	struct ast_config_include *incl,*inclnext;
+	
+	for (incl=incls; incl; incl = inclnext) {
+		inclnext = incl->next;
+		if (incl->include_location_file)
+			free(incl->include_location_file);
+		if (incl->exec_file)
+			free(incl->exec_file);
+		if (incl->included_file)
+			free(incl->included_file);
+		free(incl);
+	}
 }
 
 static struct ast_category *next_available_category(struct ast_category *cat)
@@ -648,6 +666,8 @@
 
 	if (!cfg)
 		return;
+
+	ast_includes_destroy(cfg->includes);
 
 	cat = cfg->root;
 	while (cat) {
@@ -1388,11 +1408,11 @@
 				fprintf(f,"#exec \"%s\"\n", incl->exec_file);
 			else
 				fprintf(f,"#include \"%s\"\n", incl->included_file);
+			fclose(f);
 			incl->output = 1;
 		}
 	}
 				
-	fclose(f);
 	return 0;
 }
 




More information about the asterisk-commits mailing list