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
1.6.0
Kevin P. Fleming 19 years ago
parent b30b1bc46f
commit a34bbab643

@ -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)

@ -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)

Loading…
Cancel
Save