From edc78d6023c379c19afff8c94632d7118295ff60 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Thu, 8 Nov 2007 05:28:47 +0000 Subject: improve linked-list macros in two ways: - the *_CURRENT macros no longer need the list head pointer argument - add AST_LIST_MOVE_CURRENT to encapsulate the remove/add operation when moving entries between lists git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89106 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/pbx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'main/pbx.c') diff --git a/main/pbx.c b/main/pbx.c index d740e91cd..d3949ecf1 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -1514,12 +1514,12 @@ int ast_custom_function_unregister(struct ast_custom_function *acf) AST_RWLIST_WRLOCK(&acf_root); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { if (cur == acf) { - AST_RWLIST_REMOVE_CURRENT(&acf_root, acflist); + AST_RWLIST_REMOVE_CURRENT(acflist); ast_verb(2, "Unregistered custom function %s\n", acf->name); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&acf_root); return acf ? 0 : -1; @@ -1547,11 +1547,11 @@ int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_m /* Store in alphabetical order */ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { if (strcasecmp(acf->name, cur->name) < 0) { - AST_RWLIST_INSERT_BEFORE_CURRENT(&acf_root, acf, acflist); + AST_RWLIST_INSERT_BEFORE_CURRENT(acf, acflist); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; if (!cur) AST_RWLIST_INSERT_TAIL(&acf_root, acf, acflist); @@ -2361,13 +2361,13 @@ static int ast_remove_hint(struct ast_exten *e) ast_free(cbprev); } hint->callbacks = NULL; - AST_RWLIST_REMOVE_CURRENT(&hints, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_free(hint); res = 0; break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; return res; } @@ -2935,13 +2935,13 @@ int ast_context_remove_switch2(struct ast_context *con, const char *sw, const ch if (!strcmp(i->name, sw) && !strcmp(i->data, data) && (!registrar || !strcmp(i->registrar, registrar))) { /* found, remove from list */ - AST_LIST_REMOVE_CURRENT(&con->alts, list); + AST_LIST_REMOVE_CURRENT(list); ast_free(i); /* free switch and return */ ret = 0; break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; ast_unlock_context(con); @@ -3136,11 +3136,11 @@ int ast_register_application2(const char *app, int (*execute)(struct ast_channel /* Store in alphabetical order */ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, cur, list) { if (strcasecmp(tmp->name, cur->name) < 0) { - AST_RWLIST_INSERT_BEFORE_CURRENT(&apps, tmp, list); + AST_RWLIST_INSERT_BEFORE_CURRENT(tmp, list); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; if (!cur) AST_RWLIST_INSERT_TAIL(&apps, tmp, list); @@ -4023,13 +4023,13 @@ int ast_unregister_application(const char *app) AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, tmp, list) { if (!strcasecmp(app, tmp->name)) { unreference_cached_app(tmp); - AST_RWLIST_REMOVE_CURRENT(&apps, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_verb(2, "Unregistered application '%s'\n", tmp->name); ast_free(tmp); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&apps); return tmp ? 0 : -1; -- cgit v1.2.3