summaryrefslogtreecommitdiff
path: root/apps
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 /apps
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 'apps')
-rw-r--r--apps/app_followme.c10
-rw-r--r--apps/app_meetme.c26
-rw-r--r--apps/app_queue.c2
-rw-r--r--apps/app_voicemail.c4
4 files changed, 19 insertions, 23 deletions
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 0624157df..c5a5723ac 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -840,13 +840,12 @@ static void findmeexec(struct fm_args *tpargs)
winner = wait_for_winner(findme_user_list, nm, caller, tpargs->namerecloc, &status, tpargs);
- AST_LIST_TRAVERSE_SAFE_BEGIN(findme_user_list, fmuser, entry) {
+ while ((fmuser = AST_LIST_REMOVE_HEAD(findme_user_list, entry))) {
if (!fmuser->cleared && fmuser->ochan != winner)
clear_caller(fmuser);
- AST_LIST_REMOVE_CURRENT(findme_user_list, entry);
ast_free(fmuser);
}
- AST_LIST_TRAVERSE_SAFE_END
+
fmuser = NULL;
tmpuser = NULL;
headuser = NULL;
@@ -978,11 +977,8 @@ static int app_exec(struct ast_channel *chan, void *data)
findmeexec(&targs);
- AST_LIST_TRAVERSE_SAFE_BEGIN(&targs.cnumbers, nm, entry) {
- AST_LIST_REMOVE_CURRENT(&targs.cnumbers, entry);
+ while ((nm = AST_LIST_REMOVE_HEAD(&targs.cnumbers, entry)))
ast_free(nm);
- }
- AST_LIST_TRAVERSE_SAFE_END
if (!ast_strlen_zero(namerecloc))
unlink(namerecloc);
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 48014ed79..4cebb6315 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -3971,14 +3971,14 @@ static struct sla_ringing_trunk *sla_choose_ringing_trunk(struct sla_station *st
continue;
if (remove)
- AST_LIST_REMOVE_CURRENT(&sla.ringing_trunks, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
if (trunk_ref)
*trunk_ref = s_trunk_ref;
break;
}
- AST_LIST_TRAVERSE_SAFE_END
+ AST_LIST_TRAVERSE_SAFE_END;
if (ringing_trunk)
break;
@@ -4006,11 +4006,11 @@ static void sla_handle_dial_state_event(void)
case AST_DIAL_RESULT_FAILED:
case AST_DIAL_RESULT_TIMEOUT:
case AST_DIAL_RESULT_UNANSWERED:
- AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
sla_stop_ringing_station(ringing_station, SLA_STATION_HANGUP_NORMAL);
break;
case AST_DIAL_RESULT_ANSWERED:
- AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
/* Find the appropriate trunk to answer. */
ast_mutex_lock(&sla.lock);
ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1);
@@ -4055,7 +4055,7 @@ static void sla_handle_dial_state_event(void)
break;
}
}
- AST_LIST_TRAVERSE_SAFE_END
+ AST_LIST_TRAVERSE_SAFE_END;
}
/*! \brief Check to see if this station is already ringing
@@ -4085,7 +4085,7 @@ static int sla_check_failed_station(const struct sla_station *station)
if (station != failed_station->station)
continue;
if (ast_tvdiff_ms(ast_tvnow(), failed_station->last_try) > 1000) {
- AST_LIST_REMOVE_CURRENT(&sla.failed_stations, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
ast_free(failed_station);
break;
}
@@ -4284,7 +4284,7 @@ static void sla_hangup_stations(void)
break;
}
if (!trunk_ref) {
- AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
ast_dial_join(ringing_station->station->dial);
ast_dial_destroy(ringing_station->station->dial);
ringing_station->station->dial = NULL;
@@ -4341,7 +4341,7 @@ static int sla_calc_trunk_timeouts(unsigned int *timeout)
time_left = (ringing_trunk->trunk->ring_timeout * 1000) - time_elapsed;
if (time_left <= 0) {
pbx_builtin_setvar_helper(ringing_trunk->trunk->chan, "SLATRUNK_STATUS", "RINGTIMEOUT");
- AST_LIST_REMOVE_CURRENT(&sla.ringing_trunks, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
sla_stop_ringing_trunk(ringing_trunk);
res = 1;
continue;
@@ -4349,7 +4349,7 @@ static int sla_calc_trunk_timeouts(unsigned int *timeout)
if (time_left < *timeout)
*timeout = time_left;
}
- AST_LIST_TRAVERSE_SAFE_END
+ AST_LIST_TRAVERSE_SAFE_END;
return res;
}
@@ -4422,7 +4422,7 @@ static int sla_calc_station_timeouts(unsigned int *timeout)
/* If there is no time left, the station needs to stop ringing */
if (time_left <= 0) {
- AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
sla_stop_ringing_station(ringing_station, SLA_STATION_HANGUP_TIMEOUT);
res = 1;
continue;
@@ -4433,7 +4433,7 @@ static int sla_calc_station_timeouts(unsigned int *timeout)
if (time_left < *timeout)
*timeout = time_left;
}
- AST_LIST_TRAVERSE_SAFE_END
+ AST_LIST_TRAVERSE_SAFE_END;
return res;
}
@@ -4992,11 +4992,11 @@ static int sla_trunk_exec(struct ast_channel *chan, void *data)
ast_mutex_lock(&sla.lock);
AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) {
if (ringing_trunk->trunk == trunk) {
- AST_LIST_REMOVE_CURRENT(&sla.ringing_trunks, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
break;
}
}
- AST_LIST_TRAVERSE_SAFE_END
+ AST_LIST_TRAVERSE_SAFE_END;
ast_mutex_unlock(&sla.lock);
if (ringing_trunk) {
sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 9b6ed81b6..9042149c0 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -933,7 +933,7 @@ static int remove_from_interfaces(const char *interface)
if (!strcasecmp(curint->interface, interface)) {
if (!interface_exists_global(interface)) {
ast_debug(1, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
- AST_LIST_REMOVE_CURRENT(&interfaces, list);
+ AST_LIST_REMOVE_CURRENT(list);
ast_free(curint);
}
break;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 0d98b18de..1be987439 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -4381,7 +4381,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir);
#endif
saved_messages++;
- AST_LIST_REMOVE_CURRENT(&extensions, list);
+ AST_LIST_REMOVE_CURRENT(list);
free_user(vmtmp);
if (res)
break;
@@ -7804,7 +7804,7 @@ static void mwi_unsub_event_cb(const struct ast_event *event, void *userdata)
AST_RWLIST_WRLOCK(&mwi_subs);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&mwi_subs, mwi_sub, entry) {
if (mwi_sub->uniqueid == uniqueid) {
- AST_LIST_REMOVE_CURRENT(&mwi_subs, entry);
+ AST_LIST_REMOVE_CURRENT(entry);
break;
}
}