diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2007-11-14 00:54:38 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2007-11-14 00:54:38 +0000 |
commit | a34bbab643118026a1709cce2eb88b0e43153613 (patch) | |
tree | ea2278dbcdc050b8a4e5b2f72d5c58d988314aab /main | |
parent | b30b1bc46fb23f80ea19b2227e8e98085249a3b9 (diff) |
use simpler technique for removing known entries from lists
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89259 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/channel.c | 15 | ||||
-rw-r--r-- | main/pbx.c | 12 |
2 files changed, 4 insertions, 23 deletions
diff --git a/main/channel.c b/main/channel.c index 288d759f2..c914b6b7b 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1250,20 +1250,7 @@ int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *da int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore) { - struct ast_datastore *datastore2 = NULL; - int res = -1; - - /* Find our position and remove ourselves */ - AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore2, entry) { - if (datastore2 == datastore) { - AST_LIST_REMOVE_CURRENT(entry); - res = 0; - break; - } - } - AST_LIST_TRAVERSE_SAFE_END; - - return res; + return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1; } struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid) diff --git a/main/pbx.c b/main/pbx.c index 72a2ffa2d..cd2b27c82 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -2103,17 +2103,11 @@ int ast_custom_function_unregister(struct ast_custom_function *acf) return -1; AST_RWLIST_WRLOCK(&acf_root); - AST_RWLIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { - if (cur == acf) { - AST_RWLIST_REMOVE_CURRENT(acflist); - ast_verb(2, "Unregistered custom function %s\n", acf->name); - break; - } - } - AST_RWLIST_TRAVERSE_SAFE_END; + if ((cur = AST_RWLIST_REMOVE(&acf_root, acf, acflist))) + ast_verb(2, "Unregistered custom function %s\n", cur->name); AST_RWLIST_UNLOCK(&acf_root); - return acf ? 0 : -1; + return cur ? 0 : -1; } int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod) |