[Freeswitch-trunk] [commit] r14031 - freeswitch/trunk/contrib/ledr/mod_xml_odbc

FreeSWITCH SVN ledr at freeswitch.org
Mon Jun 29 11:01:47 PDT 2009


Author: ledr
Date: Mon Jun 29 13:01:46 2009
New Revision: 14031

Log:
Got rid of some memory leaks, main leak left is strdup to switch_xml_t name


Modified:
   freeswitch/trunk/contrib/ledr/mod_xml_odbc/mod_xml_odbc.c

Modified: freeswitch/trunk/contrib/ledr/mod_xml_odbc/mod_xml_odbc.c
==============================================================================
--- freeswitch/trunk/contrib/ledr/mod_xml_odbc/mod_xml_odbc.c	(original)
+++ freeswitch/trunk/contrib/ledr/mod_xml_odbc/mod_xml_odbc.c	Mon Jun 29 13:01:46 2009
@@ -271,6 +271,11 @@
 			char *tmp_attr;
 			tmp_attr = switch_event_expand_headers(params, xml_in->attr[i+1]);
 			switch_xml_set_attr(xml_out, xml_in->attr[i], tmp_attr);
+
+			if (tmp_attr != xml_in->attr[i+1]) {
+				switch_safe_free(tmp_attr);
+			}
+
 		}
 
 		/* copy all children and render them */
@@ -285,13 +290,11 @@
 	status = SWITCH_STATUS_SUCCESS;
 
   done:
-/* what must I free here : */
-//	switch_xml_free(xml_in_tmp);
-//	switch_safe_free(name);
-//	switch_safe_free(value);
-//	switch_safe_free(new_value);
-//	switch_safe_free(empty_result_break_to);
-//	switch_safe_free(no_template_break_to);
+
+	if (value != new_value) {
+		switch_safe_free(new_value);
+	}
+
 	return status;
 }
 
@@ -377,7 +380,9 @@
 	}
 
 	if (debug == SWITCH_TRUE) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Debug dump of XML generated:\n%s", switch_xml_toxml(xml_out, SWITCH_FALSE));
+		char *tmp_xml = switch_xml_toxml(xml_out, SWITCH_FALSE);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Debug dump of XML generated:\n%s", tmp_xml);
+		switch_safe_free(tmp_xml);
 	}
 
 	ret = 0;
@@ -573,6 +578,8 @@
 	switch_odbc_handle_disconnect(globals.master_odbc);
 	switch_odbc_handle_destroy(&globals.master_odbc);
 
+	switch_xml_unbind_search_function_ptr(xml_odbc_search);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 



More information about the Freeswitch-trunk mailing list