diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index fe09610ff6418d08ca2afcb9faa87232c5573929..d7447d12f4c3ffe48319eae69f41c7dc81c0a07c 100644 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -461,6 +461,23 @@ struct { \ } \ } while (0) +/*! + \brief Appends a whole list to the tail of a list. + \param head This is a pointer to the list head structure + \param list This is a pointer to the list to be appended. + \param field This is the name of the field (declared using AST_LIST_ENTRY()) + used to link entries of this list together. + */ +#define AST_LIST_APPEND_LIST(head, list, field) do { \ + if (!(head)->first) { \ + (head)->first = (list)->first; \ + (head)->last = (list)->last; \ + } else { \ + (head)->last->field.next = (list)->first; \ + (head)->last = (list)->last; \ + } \ +} while (0) + /*! \brief Removes and returns the head entry from a list. \param head This is a pointer to the list head structure diff --git a/main/channel.c b/main/channel.c index 66649bc33b7850ec97165ebe0ac5cad784c62f13..f2cc5fa1422f61b54ca30ddd5ae91462a7a7b5a7 100644 --- a/main/channel.c +++ b/main/channel.c @@ -3046,7 +3046,7 @@ static void clone_variables(struct ast_channel *original, struct ast_channel *cl AST_LIST_TRAVERSE_SAFE_BEGIN(&original->varshead, varptr, entries) { if (!strncmp(ast_var_name(varptr), GROUP_CATEGORY_PREFIX, strlen(GROUP_CATEGORY_PREFIX))) { - AST_LIST_REMOVE(&original->varshead, varptr, entries); + AST_LIST_REMOVE_CURRENT(&original->varshead, entries); ast_var_delete(varptr); } } @@ -3055,7 +3055,7 @@ static void clone_variables(struct ast_channel *original, struct ast_channel *cl /* Append variables from clone channel into original channel */ /* XXX Is this always correct? We have to in order to keep MACROS working XXX */ if (AST_LIST_FIRST(&clone->varshead)) - AST_LIST_INSERT_TAIL(&original->varshead, AST_LIST_FIRST(&clone->varshead), entries); + AST_LIST_APPEND_LIST(&original->varshead, &clone->varshead, entries); } /*! diff --git a/main/pbx.c b/main/pbx.c index feae6d16df6f871350d5225536423799ae76d6cb..31f554acdce11ea98fcbb684df2833383763ae66 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -5360,9 +5360,9 @@ int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t memset(buf, 0, size); AST_LIST_TRAVERSE(&chan->varshead, variables, entries) { - if(variables && - (var=ast_var_name(variables)) && (val=ast_var_value(variables)) && - !ast_strlen_zero(var) && !ast_strlen_zero(val)) { + if ((var=ast_var_name(variables)) && (val=ast_var_value(variables)) + /* && !ast_strlen_zero(var) && !ast_strlen_zero(val) */ + ) { if (ast_build_string(&buf, &size, "%s=%s\n", var, val)) { ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n"); break;