use simpler technique for removing known entries from lists
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 14 Nov 2007 00:54:38 +0000 (00:54 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 14 Nov 2007 00:54:38 +0000 (00:54 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89259 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c
main/pbx.c

index 288d759..c914b6b 100644 (file)
@@ -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)
index 72a2ffa..cd2b27c 100644 (file)
@@ -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)