minor code simplifications - no need to use temporary
authorLuigi Rizzo <rizzo@icir.org>
Fri, 31 Mar 2006 09:50:54 +0000 (09:50 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Fri, 31 Mar 2006 09:50:54 +0000 (09:50 +0000)
variables.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16639 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx/pbx_loopback.c

index ffa0065..5f590cf 100644 (file)
@@ -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, ':');