summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2007-11-08 05:28:47 +0000
committerKevin P. Fleming <kpfleming@digium.com>2007-11-08 05:28:47 +0000
commitedc78d6023c379c19afff8c94632d7118295ff60 (patch)
tree444ea944312fd31b5524ee43f8cfc97e2884c6de /res
parent950528b638cc290e4ea661ec3426f73230703e9e (diff)
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
Diffstat (limited to 'res')
-rw-r--r--res/res_agi.c4
-rw-r--r--res/res_crypto.c4
-rw-r--r--res/res_features.c6
-rw-r--r--res/res_jabber.c4
-rw-r--r--res/res_musiconhold.c4
-rw-r--r--res/res_odbc.c6
-rw-r--r--res/res_speech.c4
7 files changed, 15 insertions, 17 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 293d54b6a..bb591c169 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -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);
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 17b7789c3..b32837b34 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -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);
}
diff --git a/res/res_features.c b/res/res_features.c
index a779da035..e4fec5305 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -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;
}
}
diff --git a/res/res_jabber.c b/res/res_jabber.c
index c4d626ccb..464f6a22c 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -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)
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 374864b54..a1de8ba6b 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -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);
}
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 6475e33b9..0b3887232 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -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(&current->lock);
ast_free(current);
}
- AST_LIST_TRAVERSE_SAFE_END;
- AST_LIST_REMOVE_CURRENT(&odbc_list, list);
+ AST_LIST_REMOVE_CURRENT(list);
ast_free(class);
}
}
diff --git a/res/res_speech.c b/res/res_speech.c
index cb096d3d9..27b1d3235 100644
--- a/res/res_speech.c
+++ b/res/res_speech.c
@@ -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;