[asterisk-commits] pbx.c: Remove duplicate code. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 25 19:47:30 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: pbx.c: Remove duplicate code.
......................................................................


pbx.c: Remove duplicate code.

Merge code found in both branches of a conditional in
ast_add_extension2_lockopt.

The updated code initializes peer_table and peer_label_table of the
extension before linking it to the context.

Change-Id: Ic759e27cdc9906c6877df41d28ee9c5be8f41c20
---
M main/pbx.c
1 file changed, 19 insertions(+), 33 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/main/pbx.c b/main/pbx.c
index f9fad03..4d6d31e 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -7278,52 +7278,38 @@
 		 * so insert in the main list right before 'e' (if any)
 		 */
 		tmp->next = e;
-		if (el) {  /* there is another exten already in this context */
-			el->next = tmp;
-			tmp->peer_table = ast_hashtab_create(13,
-							hashtab_compare_exten_numbers,
+		tmp->peer_table = ast_hashtab_create(13,
+						hashtab_compare_exten_numbers,
+						ast_hashtab_resize_java,
+						ast_hashtab_newsize_java,
+						hashtab_hash_priority,
+						0);
+		tmp->peer_label_table = ast_hashtab_create(7,
+							hashtab_compare_exten_labels,
 							ast_hashtab_resize_java,
 							ast_hashtab_newsize_java,
-							hashtab_hash_priority,
+							hashtab_hash_labels,
 							0);
-			tmp->peer_label_table = ast_hashtab_create(7,
-								hashtab_compare_exten_labels,
-								ast_hashtab_resize_java,
-								ast_hashtab_newsize_java,
-								hashtab_hash_labels,
-								0);
-			if (label) {
-				ast_hashtab_insert_safe(tmp->peer_label_table, tmp);
-			}
-			ast_hashtab_insert_safe(tmp->peer_table, tmp);
+
+		if (el) {  /* there is another exten already in this context */
+			el->next = tmp;
 		} else {  /* this is the first exten in this context */
-			if (!con->root_table)
+			if (!con->root_table) {
 				con->root_table = ast_hashtab_create(27,
 													hashtab_compare_extens,
 													ast_hashtab_resize_java,
 													ast_hashtab_newsize_java,
 													hashtab_hash_extens,
 													0);
-			con->root = tmp;
-			con->root->peer_table = ast_hashtab_create(13,
-								hashtab_compare_exten_numbers,
-								ast_hashtab_resize_java,
-								ast_hashtab_newsize_java,
-								hashtab_hash_priority,
-								0);
-			con->root->peer_label_table = ast_hashtab_create(7,
-									hashtab_compare_exten_labels,
-									ast_hashtab_resize_java,
-									ast_hashtab_newsize_java,
-									hashtab_hash_labels,
-									0);
-			if (label) {
-				ast_hashtab_insert_safe(con->root->peer_label_table, tmp);
 			}
-			ast_hashtab_insert_safe(con->root->peer_table, tmp);
-
+			con->root = tmp;
 		}
+		if (label) {
+			ast_hashtab_insert_safe(tmp->peer_label_table, tmp);
+		}
+		ast_hashtab_insert_safe(tmp->peer_table, tmp);
 		ast_hashtab_insert_safe(con->root_table, tmp);
+
 		if (lock_context) {
 			ast_unlock_context(con);
 		}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic759e27cdc9906c6877df41d28ee9c5be8f41c20
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-commits mailing list