[Asterisk-code-review] manager channels.c: Reordered ast manager build channel stat... (asterisk[15])

Richard Mudgett asteriskteam at digium.com
Thu Feb 1 12:28:23 CST 2018


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/8127


Change subject: manager_channels.c: Reordered ast_manager_build_channel_state_string_prefix()
......................................................................

manager_channels.c: Reordered ast_manager_build_channel_state_string_prefix()

* Made not allocate memory if the channel snapshot is an internal channel.

* Free memory earlier when no longer needed.

Change-Id: Ia06e0c065f1bd095781aa3f4a626d58fa4d28b38
---
M main/manager_channels.c
1 file changed, 10 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/27/8127/1

diff --git a/main/manager_channels.c b/main/manager_channels.c
index 81dafd7..37269a9 100644
--- a/main/manager_channels.c
+++ b/main/manager_channels.c
@@ -488,16 +488,17 @@
 		const struct ast_channel_snapshot *snapshot,
 		const char *prefix)
 {
-	struct ast_str *out = ast_str_create(1024);
-	int res = 0;
-	char *caller_name, *connected_name;
+	struct ast_str *out;
+	char *caller_name;
+	char *connected_name;
+	int res;
 
-	if (!out) {
+	if (snapshot->tech_properties & AST_CHAN_TP_INTERNAL) {
 		return NULL;
 	}
 
-	if (snapshot->tech_properties & AST_CHAN_TP_INTERNAL) {
-		ast_free(out);
+	out = ast_str_create(1024);
+	if (!out) {
 		return NULL;
 	}
 
@@ -534,10 +535,11 @@
 		prefix, snapshot->uniqueid,
 		prefix, snapshot->linkedid);
 
+	ast_free(caller_name);
+	ast_free(connected_name);
+
 	if (!res) {
 		ast_free(out);
-		ast_free(caller_name);
-		ast_free(connected_name);
 		return NULL;
 	}
 
@@ -552,9 +554,6 @@
 			ast_free(val);
 		}
 	}
-
-	ast_free(caller_name);
-	ast_free(connected_name);
 
 	return out;
 }

-- 
To view, visit https://gerrit.asterisk.org/8127
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia06e0c065f1bd095781aa3f4a626d58fa4d28b38
Gerrit-Change-Number: 8127
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180201/cd6356d0/attachment.html>


More information about the asterisk-code-review mailing list