diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-12-23 15:11:46 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-12-23 15:11:46 +0000 |
commit | 8f2fabe64f24fdfd17dcc34773bdb2adb1ef1b7e (patch) | |
tree | eadb7c681e0fecd6f7d64f2cfe5c72dedc2cd7c3 | |
parent | bda9898fe134a95231748b1419ad951f413aaf08 (diff) |
Speed up ast_list macros (bug #3135)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4546 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | channel.c | 3 | ||||
-rwxr-xr-x | doc/linkedlists.README | 8 | ||||
-rwxr-xr-x | include/asterisk/linkedlists.h | 8 | ||||
-rwxr-xr-x | pbx.c | 3 | ||||
-rwxr-xr-x | pbx/pbx_dundi.c | 3 | ||||
-rwxr-xr-x | pbx/pbx_loopback.c | 3 |
6 files changed, 13 insertions, 15 deletions
@@ -641,8 +641,7 @@ void ast_channel_free(struct ast_channel *chan) /* no need to lock the list, as the channel is already locked */ while (!AST_LIST_EMPTY(headp)) { /* List Deletion. */ - vardata = AST_LIST_FIRST(headp); - AST_LIST_REMOVE_HEAD(headp, entries); + vardata = AST_LIST_REMOVE_HEAD(headp, ast_var_t, entries); /* printf("deleting var %s=%s\n",ast_var_name(vardata),ast_var_value(vardata)); */ ast_var_delete(vardata); } diff --git a/doc/linkedlists.README b/doc/linkedlists.README index 87e396fbc..27a8e93ae 100755 --- a/doc/linkedlists.README +++ b/doc/linkedlists.README @@ -48,9 +48,10 @@ AST_LIST_REMOVE removes an arbitrary element from the head: AST_LIST_REMOVE(headp,node1,ast_var_t,listpointers); -AST_LIST_REMOVE_HEAD removes the entry at the head of the list: +AST_LIST_REMOVE_HEAD removes the entry at the head of the list and +returns a pointer to the removed entry: - AST_LIST_REMOVE(headp,listpointers); + AST_LIST_REMOVE_HEAD(headp,node,listpointers); AST_LIST_FIRST returns a pointer to the first element of the list; @@ -78,8 +79,7 @@ To completely delete a list : struct ast_var_t *vardata; while (!AST_LIST_EMPTY(headp)) { /* List Deletion. */ - vardata = AST_LIST_FIRST(head); - AST_LIST_REMOVE_HEAD(head, listpointers); + vardata = AST_LIST_REMOVE_HEAD(head, ast_var_t, listpointers); free(vardata->name); free(vardata->value); } diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index 75f0aa2cf..c9bc7502d 100755 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -62,13 +62,15 @@ struct { \ } while (0) -#define AST_LIST_REMOVE_HEAD(head, field) do { \ +#define AST_LIST_REMOVE_HEAD(head, type, field) ({ \ + struct type *cur = (head)->first; \ (head)->first = (head)->first->field.next; \ - } while (0) + cur; \ + }) #define AST_LIST_REMOVE(head, elm, type, field) do { \ if ((head)->first == (elm)) { \ - AST_LIST_REMOVE_HEAD((head), field); \ + AST_LIST_REMOVE_HEAD((head), type, field); \ } \ else { \ struct type *curelm = (head)->first; \ @@ -5123,8 +5123,7 @@ void pbx_builtin_clear_globals(void) { struct ast_var_t *vardata; while (!AST_LIST_EMPTY(&globals)) { - vardata = AST_LIST_FIRST(&globals); - AST_LIST_REMOVE_HEAD(&globals, entries); + vardata = AST_LIST_REMOVE_HEAD(&globals, ast_var_t, entries); ast_var_delete(vardata); } } diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 602d05605..d0cab9c7d 100755 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -551,8 +551,7 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map AST_LIST_INSERT_HEAD(&headp, newvariable, entries); pbx_substitute_variables_varshead(&headp, map->dest, dr[anscnt].dest, sizeof(dr[anscnt].dest)); while (!AST_LIST_EMPTY(&headp)) { /* List Deletion. */ - newvariable = AST_LIST_FIRST(&headp); - AST_LIST_REMOVE_HEAD(&headp, entries); + newvariable = AST_LIST_REMOVE_HEAD(&headp, ast_var_t, entries); ast_var_delete(newvariable); } } else diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c index bfc9d357c..16b854099 100755 --- a/pbx/pbx_loopback.c +++ b/pbx/pbx_loopback.c @@ -81,8 +81,7 @@ static char *loopback_helper(char *buf, int buflen, const char *exten, const cha pbx_substitute_variables_varshead(&headp, data, buf, buflen); /* Substitute variables */ while (!AST_LIST_EMPTY(&headp)) { /* List Deletion. */ - newvariable = AST_LIST_FIRST(&headp); - AST_LIST_REMOVE_HEAD(&headp, entries); + newvariable = AST_LIST_REMOVE_HEAD(&headp, ast_var_t, entries); ast_var_delete(newvariable); } return buf; |