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