aboutsummaryrefslogtreecommitdiffstats
path: root/pbx/pbx_loopback.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-31 09:50:54 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-31 09:50:54 +0000
commit80b72c84c1d88534e88b114d041c5ee73af7f170 (patch)
tree3db80212b1c43fd8485403eff1bcace6b1f92b5d /pbx/pbx_loopback.c
parent81588fa8fe75f9b1f649d2bb27122a9ef3b5523f (diff)
minor code simplifications - no need to use temporary
variables. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@16639 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx/pbx_loopback.c')
-rw-r--r--pbx/pbx_loopback.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c
index ffa006527..5f590cf8a 100644
--- a/pbx/pbx_loopback.c
+++ b/pbx/pbx_loopback.c
@@ -90,18 +90,14 @@ static char *loopback_helper(char *buf, int buflen, const char *exten, const cha
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);
- pbx_substitute_variables_varshead(&headp, data, buf, buflen);
+ 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 */
- while (!AST_LIST_EMPTY(&headp)) { /* List Deletion. */
- newvariable = AST_LIST_REMOVE_HEAD(&headp, entries);
- ast_var_delete(newvariable);
- }
+ pbx_substitute_variables_varshead(&headp, data, buf, buflen);
+ /* free the list */
+ while ((newvariable = AST_LIST_REMOVE_HEAD(&headp, entries)))
+ ast_var_delete(newvariable);
return buf;
}
@@ -110,14 +106,11 @@ static void loopback_subst(char **newexten, char **newcontext, int *priority, ch
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, ':');