[svn-commits] trunk r20598 - /trunk/res/res_features.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sun Apr 16 11:49:48 MST 2006


Author: rizzo
Date: Sun Apr 16 13:49:46 2006
New Revision: 20598

URL: http://svn.digium.com/view/asterisk?rev=20598&view=rev
Log:
introduce a function to set context, extension and priority
replacing some common blocks of code (there are still a few
instances where it can be used)


Modified:
    trunk/res/res_features.c

Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?rev=20598&r1=20597&r2=20598&view=diff
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Sun Apr 16 13:49:46 2006
@@ -159,6 +159,14 @@
 	struct ast_channel *peer;
 };
 
+/* store context, priority and extension */
+static void set_c_e_p(struct ast_channel *chan, const char *ctx, const char *ext, int pri)
+{
+	ast_copy_string(chan->context, ctx, sizeof(chan->context));
+	ast_copy_string(chan->exten, ext, sizeof(chan->exten));
+	chan->priority = pri;
+}
+
 static void check_goto_on_transfer(struct ast_channel *chan) 
 {
 	struct ast_channel *xferchan;
@@ -212,7 +220,7 @@
 	ast_bridge_call(tobj->peer, tobj->chan, &tobj->bconfig);
 	ast_hangup(tobj->chan);
 	ast_hangup(tobj->peer);
-	tobj->chan = tobj->peer = NULL;
+	bzero(tobj, sizeof(*tobj)); /* XXX for safety */
 	free(tobj);
 	return NULL;
 }
@@ -372,9 +380,7 @@
 		ast_channel_masquerade(chan, rchan);
 
 		/* Setup the extensions and such */
-		ast_copy_string(chan->context, rchan->context, sizeof(chan->context));
-		ast_copy_string(chan->exten, rchan->exten, sizeof(chan->exten));
-		chan->priority = rchan->priority;
+		set_c_e_p(chan, rchan->context, rchan->exten, rchan->priority);
 
 		/* Make the masq execute */
 		f = ast_read(chan);
@@ -589,9 +595,7 @@
 			res = -1;
 		} else {
 			/* Set the channel's new extension, since it exists, using transferer context */
-			ast_copy_string(transferee->exten, newext, sizeof(transferee->exten));
-			ast_copy_string(transferee->context, transferer_real_context, sizeof(transferee->context));
-			transferee->priority = 0;
+			set_c_e_p(transferee, transferer_real_context, newext, 0);
 		}
 		check_goto_on_transfer(transferer);
 		return res;



More information about the svn-commits mailing list