[asterisk-commits] trunk r16639 - /trunk/pbx/pbx_loopback.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Mar 31 02:50:56 MST 2006


Author: rizzo
Date: Fri Mar 31 03:50:54 2006
New Revision: 16639

URL: http://svn.digium.com/view/asterisk?rev=16639&view=rev
Log:
minor code simplifications - no need to use temporary
variables.


Modified:
    trunk/pbx/pbx_loopback.c

Modified: trunk/pbx/pbx_loopback.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_loopback.c?rev=16639&r1=16638&r2=16639&view=diff
==============================================================================
--- trunk/pbx/pbx_loopback.c (original)
+++ trunk/pbx/pbx_loopback.c Fri Mar 31 03:50:54 2006
@@ -90,18 +90,14 @@
 	snprintf(tmp, sizeof(tmp), "%d", priority);
 	memset(buf, 0, buflen);
 	AST_LIST_HEAD_INIT_NOLOCK(&headp);
-	newvariable = ast_var_assign("EXTEN", exten);
-	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
-	newvariable = ast_var_assign("CONTEXT", context);
-	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
-	newvariable = ast_var_assign("PRIORITY", tmp);
-	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("EXTEN", exten), entries);
+	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("CONTEXT", context), entries);
+	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("PRIORITY", tmp), entries);
+	/* Substitute variables */
 	pbx_substitute_variables_varshead(&headp, data, buf, buflen);
-	/* Substitute variables */
-	while (!AST_LIST_EMPTY(&headp)) {           /* List Deletion. */
-		newvariable = AST_LIST_REMOVE_HEAD(&headp, entries);
-		ast_var_delete(newvariable);
-	}
+	/* free the list */
+	while ((newvariable = AST_LIST_REMOVE_HEAD(&headp, entries)))
+                ast_var_delete(newvariable);
 	return buf;
 }
 
@@ -110,14 +106,11 @@
 	char *con;
 	char *pri;
 	*newpattern = strchr(buf, '/');
-	if (*newpattern) {
-		*(*newpattern) = '\0';
-		(*newpattern)++;
-	}
+	if (*newpattern)
+		*(*newpattern)++ = '\0';
 	con = strchr(buf, '@');
 	if (con) {
-		*con = '\0';
-		con++;
+		*con++ = '\0';
 		pri = strchr(con, ':');
 	} else
 		pri = strchr(buf, ':');



More information about the asterisk-commits mailing list