mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
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
This commit is contained in:
@@ -1701,14 +1701,14 @@ int ast_agi_unregister(struct ast_module *mod, agi_command *cmd)
|
||||
AST_RWLIST_WRLOCK(&agi_commands);
|
||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&agi_commands, e, list) {
|
||||
if (cmd == e) {
|
||||
AST_RWLIST_REMOVE_CURRENT(&agi_commands, list);
|
||||
AST_RWLIST_REMOVE_CURRENT(list);
|
||||
if (mod != ast_module_info->self)
|
||||
ast_module_unref(ast_module_info->self);
|
||||
unregistered=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
AST_RWLIST_TRAVERSE_SAFE_END
|
||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||
AST_RWLIST_UNLOCK(&agi_commands);
|
||||
if (unregistered)
|
||||
ast_verb(2, "AGI Command '%s' unregistered\n",fullcmd);
|
||||
|
@@ -474,13 +474,13 @@ static void crypto_load(int ifd, int ofd)
|
||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&keys, key, list) {
|
||||
if (key->delme) {
|
||||
ast_debug(1, "Deleting key %s type %d\n", key->name, key->ktype);
|
||||
AST_RWLIST_REMOVE_CURRENT(&keys, list);
|
||||
AST_RWLIST_REMOVE_CURRENT(list);
|
||||
if (key->rsa)
|
||||
RSA_free(key->rsa);
|
||||
ast_free(key);
|
||||
}
|
||||
}
|
||||
AST_RWLIST_TRAVERSE_SAFE_END
|
||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||
|
||||
AST_RWLIST_UNLOCK(&keys);
|
||||
}
|
||||
|
@@ -2129,7 +2129,7 @@ static void *do_parking_thread(void *ignore)
|
||||
ast_hangup(chan);
|
||||
}
|
||||
/* And take them out of the parking lot */
|
||||
AST_LIST_REMOVE_CURRENT(&parkinglot, list);
|
||||
AST_LIST_REMOVE_CURRENT(list);
|
||||
con = ast_context_find(parking_con);
|
||||
if (con) {
|
||||
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
|
||||
@@ -2163,7 +2163,7 @@ static void *do_parking_thread(void *ignore)
|
||||
ast_verb(2, "%s got tired of being parked\n", chan->name);
|
||||
ast_hangup(chan);
|
||||
/* And take them out of the parking lot */
|
||||
AST_LIST_REMOVE_CURRENT(&parkinglot, list);
|
||||
AST_LIST_REMOVE_CURRENT(list);
|
||||
con = ast_context_find(parking_con);
|
||||
if (con) {
|
||||
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
|
||||
@@ -2270,7 +2270,7 @@ static int park_exec(struct ast_channel *chan, void *data)
|
||||
AST_LIST_LOCK(&parkinglot);
|
||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&parkinglot, pu, list) {
|
||||
if (pu->parkingnum == park) {
|
||||
AST_LIST_REMOVE_CURRENT(&parkinglot, list);
|
||||
AST_LIST_REMOVE_CURRENT(list);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -1493,14 +1493,14 @@ static void aji_handle_message(struct aji_client *client, ikspak *pak)
|
||||
AST_LIST_LOCK(&client->messages);
|
||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&client->messages, tmp, list) {
|
||||
if (flag) {
|
||||
AST_LIST_REMOVE_CURRENT(&client->messages, list);
|
||||
AST_LIST_REMOVE_CURRENT(list);
|
||||
if (tmp->from)
|
||||
ast_free(tmp->from);
|
||||
if (tmp->message)
|
||||
ast_free(tmp->message);
|
||||
} else if (difftime(time(NULL), tmp->arrived) >= client->message_timeout) {
|
||||
flag = 1;
|
||||
AST_LIST_REMOVE_CURRENT(&client->messages, list);
|
||||
AST_LIST_REMOVE_CURRENT(list);
|
||||
if (tmp->from)
|
||||
ast_free(tmp->from);
|
||||
if (tmp->message)
|
||||
|
@@ -1293,14 +1293,14 @@ static int init_classes(int reload)
|
||||
AST_RWLIST_WRLOCK(&mohclasses);
|
||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&mohclasses, moh, list) {
|
||||
if (reload && moh->delete) {
|
||||
AST_RWLIST_REMOVE_CURRENT(&mohclasses, list);
|
||||
AST_RWLIST_REMOVE_CURRENT(list);
|
||||
if (!moh->inuse)
|
||||
ast_moh_destroy_one(moh);
|
||||
} else if (moh->total_files) {
|
||||
if (moh_scan_files(moh) <= 0) {
|
||||
ast_log(LOG_WARNING, "No files found for class '%s'\n", moh->name);
|
||||
moh->delete = 1;
|
||||
AST_LIST_REMOVE_CURRENT(&mohclasses, list);
|
||||
AST_LIST_REMOVE_CURRENT(list);
|
||||
if (!moh->inuse)
|
||||
ast_moh_destroy_one(moh);
|
||||
}
|
||||
|
@@ -706,15 +706,13 @@ static int reload(void)
|
||||
/* Purge classes that we know can go away (pooled with 0, only) */
|
||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&odbc_list, class, list) {
|
||||
if (class->delme && class->haspool && class->count == 0) {
|
||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&(class->odbc_obj), current, list) {
|
||||
AST_LIST_REMOVE_CURRENT(&(class->odbc_obj), list);
|
||||
while ((current = AST_LIST_REMOVE_HEAD(&class->odbc_obj, list))) {
|
||||
odbc_obj_disconnect(current);
|
||||
ast_mutex_destroy(¤t->lock);
|
||||
ast_free(current);
|
||||
}
|
||||
AST_LIST_TRAVERSE_SAFE_END;
|
||||
|
||||
AST_LIST_REMOVE_CURRENT(&odbc_list, list);
|
||||
AST_LIST_REMOVE_CURRENT(list);
|
||||
ast_free(class);
|
||||
}
|
||||
}
|
||||
|
@@ -317,7 +317,7 @@ int ast_speech_unregister(char *engine_name)
|
||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&engines, engine, list) {
|
||||
if (!strcasecmp(engine->name, engine_name)) {
|
||||
/* We have our engine... removed it */
|
||||
AST_RWLIST_REMOVE_CURRENT(&engines, list);
|
||||
AST_RWLIST_REMOVE_CURRENT(list);
|
||||
/* If this was the default engine, we need to pick a new one */
|
||||
if (!default_engine)
|
||||
default_engine = AST_RWLIST_FIRST(&engines);
|
||||
@@ -327,7 +327,7 @@ int ast_speech_unregister(char *engine_name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
AST_RWLIST_TRAVERSE_SAFE_END
|
||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||
AST_RWLIST_UNLOCK(&engines);
|
||||
|
||||
return res;
|
||||
|
Reference in New Issue
Block a user