Make chan_local use the API call instead of inlining its own version.
authorRichard Mudgett <rmudgett@digium.com>
Mon, 14 May 2012 21:34:14 +0000 (21:34 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Mon, 14 May 2012 21:34:14 +0000 (21:34 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366462 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_local.c

index a37a4a4..66f8814 100644 (file)
@@ -861,8 +861,8 @@ static int local_call(struct ast_channel *ast, const char *dest, int timeout)
        struct ast_channel *owner = NULL;
        struct ast_channel *chan = NULL;
        int res;
-       struct ast_var_t *varptr = NULL, *new;
-       size_t len, namelen;
+       struct ast_var_t *varptr;
+       struct ast_var_t *clone_var;
        char *reduced_dest = ast_strdupa(dest);
        char *slash;
        const char *exten;
@@ -919,12 +919,9 @@ static int local_call(struct ast_channel *ast, const char *dest, int timeout)
        /* copy the channel variables from the incoming channel to the outgoing channel */
        /* Note that due to certain assumptions, they MUST be in the same order */
        AST_LIST_TRAVERSE(ast_channel_varshead(owner), varptr, entries) {
-               namelen = strlen(varptr->name);
-               len = sizeof(struct ast_var_t) + namelen + strlen(varptr->value) + 2;
-               if ((new = ast_calloc(1, len))) {
-                       memcpy(new, varptr, len);
-                       new->value = &(new->name[0]) + namelen + 1;
-                       AST_LIST_INSERT_TAIL(ast_channel_varshead(chan), new, entries);
+               clone_var = ast_var_assign(varptr->name, varptr->value);
+               if (clone_var) {
+                       AST_LIST_INSERT_TAIL(ast_channel_varshead(chan), clone_var, entries);
                }
        }
        ast_channel_datastore_inherit(owner, chan);