diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-08 05:28:47 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-08 05:28:47 +0000 |
commit | a45a413db3bdce126d5cb28ed49b776fdebb4b1d (patch) | |
tree | 444ea944312fd31b5524ee43f8cfc97e2884c6de /main | |
parent | beabbf77e66fbdd59fdcb5e12dade8039fd0b683 (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: http://svn.digium.com/svn/asterisk/trunk@89106 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 10 | ||||
-rw-r--r-- | main/asterisk.c | 8 | ||||
-rw-r--r-- | main/astobj2.c | 4 | ||||
-rw-r--r-- | main/audiohook.c | 22 | ||||
-rw-r--r-- | main/autoservice.c | 4 | ||||
-rw-r--r-- | main/cdr.c | 9 | ||||
-rw-r--r-- | main/channel.c | 8 | ||||
-rw-r--r-- | main/cli.c | 2 | ||||
-rw-r--r-- | main/config.c | 6 | ||||
-rw-r--r-- | main/devicestate.c | 2 | ||||
-rw-r--r-- | main/event.c | 4 | ||||
-rw-r--r-- | main/file.c | 4 | ||||
-rw-r--r-- | main/frame.c | 5 | ||||
-rw-r--r-- | main/image.c | 4 | ||||
-rw-r--r-- | main/indications.c | 8 | ||||
-rw-r--r-- | main/loader.c | 10 | ||||
-rw-r--r-- | main/logger.c | 4 | ||||
-rw-r--r-- | main/manager.c | 12 | ||||
-rw-r--r-- | main/pbx.c | 24 | ||||
-rw-r--r-- | main/sched.c | 8 | ||||
-rw-r--r-- | main/srv.c | 8 | ||||
-rw-r--r-- | main/translate.c | 4 |
22 files changed, 80 insertions, 90 deletions
diff --git a/main/app.c b/main/app.c index f08c83929..f21a40e47 100644 --- a/main/app.c +++ b/main/app.c @@ -873,12 +873,12 @@ int ast_app_group_set_channel(struct ast_channel *chan, const char *data) AST_RWLIST_WRLOCK(&groups); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) { if ((gi->chan == chan) && ((ast_strlen_zero(category) && ast_strlen_zero(gi->category)) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) { - AST_RWLIST_REMOVE_CURRENT(&groups, list); + AST_RWLIST_REMOVE_CURRENT(list); free(gi); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; if (ast_strlen_zero(group)) { /* Enable unsetting the group */ @@ -964,11 +964,11 @@ int ast_app_group_discard(struct ast_channel *chan) AST_RWLIST_WRLOCK(&groups); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) { if (gi->chan == chan) { - AST_RWLIST_REMOVE_CURRENT(&groups, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_free(gi); } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&groups); return 0; @@ -1204,7 +1204,7 @@ static int ast_unlock_path_flock(const char *path) AST_LIST_LOCK(&path_lock_list); AST_LIST_TRAVERSE_SAFE_BEGIN(&path_lock_list, p, le) { if (!strcmp(p->path, path)) { - AST_LIST_REMOVE_CURRENT(&path_lock_list, le); + AST_LIST_REMOVE_CURRENT(le); break; } } diff --git a/main/asterisk.c b/main/asterisk.c index 61c4ea526..7ba306233 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -286,7 +286,7 @@ void ast_unregister_file_version(const char *file) AST_RWLIST_WRLOCK(&file_versions); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&file_versions, find, list) { if (!strcasecmp(find->file, file)) { - AST_RWLIST_REMOVE_CURRENT(&file_versions, list); + AST_RWLIST_REMOVE_CURRENT(list); break; } } @@ -325,7 +325,7 @@ void ast_unregister_thread(void *id) AST_RWLIST_WRLOCK(&thread_list); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&thread_list, x, list) { if ((void *) x->id == id) { - AST_RWLIST_REMOVE_CURRENT(&thread_list, list); + AST_RWLIST_REMOVE_CURRENT(list); break; } } @@ -747,11 +747,11 @@ void ast_unregister_atexit(void (*func)(void)) AST_RWLIST_WRLOCK(&atexits); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&atexits, ae, list) { if (ae->func == func) { - AST_RWLIST_REMOVE_CURRENT(&atexits, list); + AST_RWLIST_REMOVE_CURRENT(list); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&atexits); if (ae) diff --git a/main/astobj2.c b/main/astobj2.c index c9c468017..8404f036d 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -467,7 +467,7 @@ void *ao2_callback(struct ao2_container *c, /* we are going to modify the container, so update version */ ast_atomic_fetchadd_int(&c->version, 1); - AST_LIST_REMOVE_CURRENT(&c->buckets[i], entry); + AST_LIST_REMOVE_CURRENT(entry); /* update number of elements and version */ ast_atomic_fetchadd_int(&c->elements, -1); ao2_ref(EXTERNAL_OBJ(x->astobj), -1); @@ -488,7 +488,7 @@ void *ao2_callback(struct ao2_container *c, #endif } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; } ao2_unlock(c); return ret; diff --git a/main/audiohook.c b/main/audiohook.c index d1dc6d0fd..4b7eacbca 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -346,35 +346,29 @@ int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list) struct ast_audiohook *audiohook = NULL; /* Drop any spies */ - AST_LIST_TRAVERSE_SAFE_BEGIN(&audiohook_list->spy_list, audiohook, list) { + while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->spy_list, list))) { ast_audiohook_lock(audiohook); - AST_LIST_REMOVE_CURRENT(&audiohook_list->spy_list, list); audiohook->status = AST_AUDIOHOOK_STATUS_DONE; ast_cond_signal(&audiohook->trigger); ast_audiohook_unlock(audiohook); } - AST_LIST_TRAVERSE_SAFE_END /* Drop any whispering sources */ - AST_LIST_TRAVERSE_SAFE_BEGIN(&audiohook_list->whisper_list, audiohook, list) { + while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->whisper_list, list))) { ast_audiohook_lock(audiohook); - AST_LIST_REMOVE_CURRENT(&audiohook_list->whisper_list, list); audiohook->status = AST_AUDIOHOOK_STATUS_DONE; ast_cond_signal(&audiohook->trigger); ast_audiohook_unlock(audiohook); } - AST_LIST_TRAVERSE_SAFE_END /* Drop any manipulaters */ - AST_LIST_TRAVERSE_SAFE_BEGIN(&audiohook_list->manipulate_list, audiohook, list) { + while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->manipulate_list, list))) { ast_audiohook_lock(audiohook); ast_mutex_lock(&audiohook->lock); - AST_LIST_REMOVE_CURRENT(&audiohook_list->manipulate_list, list); audiohook->status = AST_AUDIOHOOK_STATUS_DONE; ast_audiohook_unlock(audiohook); audiohook->manipulate_callback(audiohook, NULL, NULL, 0); } - AST_LIST_TRAVERSE_SAFE_END /* Drop translation paths if present */ for (i = 0; i < 2; i++) { @@ -453,7 +447,7 @@ static struct ast_frame *dtmf_audiohook_write_list(struct ast_channel *chan, str AST_LIST_TRAVERSE_SAFE_BEGIN(&audiohook_list->manipulate_list, audiohook, list) { ast_audiohook_lock(audiohook); if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) { - AST_LIST_REMOVE_CURRENT(&audiohook_list->manipulate_list, list); + AST_LIST_REMOVE_CURRENT(list); audiohook->status = AST_AUDIOHOOK_STATUS_DONE; ast_audiohook_unlock(audiohook); audiohook->manipulate_callback(audiohook, NULL, NULL, 0); @@ -463,7 +457,7 @@ static struct ast_frame *dtmf_audiohook_write_list(struct ast_channel *chan, str audiohook->manipulate_callback(audiohook, chan, frame, direction); ast_audiohook_unlock(audiohook); } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; return frame; } @@ -500,7 +494,7 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st AST_LIST_TRAVERSE_SAFE_BEGIN(&audiohook_list->spy_list, audiohook, list) { ast_audiohook_lock(audiohook); if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) { - AST_LIST_REMOVE_CURRENT(&audiohook_list->spy_list, list); + AST_LIST_REMOVE_CURRENT(list); audiohook->status = AST_AUDIOHOOK_STATUS_DONE; ast_cond_signal(&audiohook->trigger); ast_audiohook_unlock(audiohook); @@ -519,7 +513,7 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st AST_LIST_TRAVERSE_SAFE_BEGIN(&audiohook_list->whisper_list, audiohook, list) { ast_audiohook_lock(audiohook); if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) { - AST_LIST_REMOVE_CURRENT(&audiohook_list->whisper_list, list); + AST_LIST_REMOVE_CURRENT(list); audiohook->status = AST_AUDIOHOOK_STATUS_DONE; ast_cond_signal(&audiohook->trigger); ast_audiohook_unlock(audiohook); @@ -544,7 +538,7 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st AST_LIST_TRAVERSE_SAFE_BEGIN(&audiohook_list->manipulate_list, audiohook, list) { ast_audiohook_lock(audiohook); if (audiohook->status != AST_AUDIOHOOK_STATUS_RUNNING) { - AST_LIST_REMOVE_CURRENT(&audiohook_list->manipulate_list, list); + AST_LIST_REMOVE_CURRENT(list); audiohook->status = AST_AUDIOHOOK_STATUS_DONE; ast_audiohook_unlock(audiohook); /* We basically drop all of our links to the manipulate audiohook and prod it to do it's own destructive things */ diff --git a/main/autoservice.c b/main/autoservice.c index 9f175bc79..7ef5c0a9b 100644 --- a/main/autoservice.c +++ b/main/autoservice.c @@ -135,14 +135,14 @@ int ast_autoservice_stop(struct ast_channel *chan) AST_RWLIST_WRLOCK(&aslist); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) { if (as->chan == chan) { - AST_RWLIST_REMOVE_CURRENT(&aslist, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_free(as); if (!ast_check_hangup(chan)) res = 0; break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; if (asthread != AST_PTHREADT_NULL) pthread_kill(asthread, SIGURG); diff --git a/main/cdr.c b/main/cdr.c index b4a185c03..166cfaeda 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -151,7 +151,7 @@ void ast_cdr_unregister(const char *name) AST_RWLIST_WRLOCK(&be_list); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&be_list, i, list) { if (!strcasecmp(name, i->name)) { - AST_RWLIST_REMOVE_CURRENT(&be_list, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_verb(2, "Unregistered '%s' CDR backend\n", name); ast_free(i); break; @@ -313,7 +313,7 @@ int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) { if (!strcasecmp(ast_var_name(newvariable), name)) { /* there is already such a variable, delete it */ - AST_LIST_REMOVE_CURRENT(headp, entries); + AST_LIST_REMOVE_CURRENT(entries); ast_var_delete(newvariable); break; } @@ -491,9 +491,8 @@ static void cdr_merge_vars(struct ast_cdr *to, struct ast_cdr *from) } else if (tovarname && strcasecmp(fromvarval,tovarval) == 0) /* if they are the same, the job is done */ continue; - /*rip this var out of the from cdr, and stick it in the to cdr */ - AST_LIST_REMOVE_CURRENT(headpfrom, entries); - AST_LIST_INSERT_HEAD(headpto, variablesfrom, entries); + /* rip this var out of the from cdr, and stick it in the to cdr */ + AST_LIST_MOVE_CURRENT(headpto, entries); } AST_LIST_TRAVERSE_SAFE_END; } diff --git a/main/channel.c b/main/channel.c index b2f993d25..a0769fa0e 100644 --- a/main/channel.c +++ b/main/channel.c @@ -451,13 +451,13 @@ void ast_channel_unregister(const struct ast_channel_tech *tech) AST_LIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) { if (chan->tech == tech) { - AST_LIST_REMOVE_CURRENT(&backends, list); + AST_LIST_REMOVE_CURRENT(list); ast_free(chan); ast_verb(2, "Unregistered channel type '%s'\n", tech->type); break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&channels); } @@ -1256,12 +1256,12 @@ int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore /* Find our position and remove ourselves */ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore2, entry) { if (datastore2 == datastore) { - AST_LIST_REMOVE_CURRENT(&chan->datastores, entry); + AST_LIST_REMOVE_CURRENT(entry); res = 0; break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; return res; } diff --git a/main/cli.c b/main/cli.c index 2277dcaaa..2cb85e474 100644 --- a/main/cli.c +++ b/main/cli.c @@ -1420,7 +1420,7 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed) if (lf < len) len = lf; if (strncasecmp(e->_full_cmd, cur->_full_cmd, len) < 0) { - AST_RWLIST_INSERT_BEFORE_CURRENT(&helpers, e, list); + AST_RWLIST_INSERT_BEFORE_CURRENT(e, list); break; } } diff --git a/main/config.c b/main/config.c index 736c5428e..59b1840fd 100644 --- a/main/config.c +++ b/main/config.c @@ -545,11 +545,9 @@ static void ast_destroy_comments(struct ast_category *cat) static void ast_destroy_template_list(struct ast_category *cat) { struct ast_category_template_instance *x; - AST_LIST_TRAVERSE_SAFE_BEGIN(&cat->template_instances, x, next) { - AST_LIST_REMOVE_CURRENT(&cat->template_instances, next); + + while ((x = AST_LIST_REMOVE_HEAD(&cat->template_instances, next))) free(x); - } - AST_LIST_TRAVERSE_SAFE_END; } void ast_category_destroy(struct ast_category *cat) diff --git a/main/devicestate.c b/main/devicestate.c index aef21f70a..c36fa694c 100644 --- a/main/devicestate.c +++ b/main/devicestate.c @@ -372,7 +372,7 @@ int ast_devstate_prov_del(const char *label) AST_RWLIST_WRLOCK(&devstate_provs); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&devstate_provs, devcb, list) { if (!strcasecmp(devcb->label, label)) { - AST_RWLIST_REMOVE_CURRENT(&devstate_provs, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_free(devcb); res = 0; break; diff --git a/main/event.c b/main/event.c index 45d582361..23b16e52c 100644 --- a/main/event.c +++ b/main/event.c @@ -708,11 +708,11 @@ int ast_event_queue_and_cache(struct ast_event *event, ...) } if (!cache_arg) { /* All parameters were matched on this cache entry, so remove it */ - AST_LIST_REMOVE_CURRENT(&ast_event_cache[host_event_type], entry); + AST_LIST_REMOVE_CURRENT(entry); ast_event_ref_destroy(event_ref); } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; res = ast_event_dup_and_cache(event); AST_RWLIST_UNLOCK(&ast_event_cache[host_event_type]); diff --git a/main/file.c b/main/file.c index 3fb5fa845..de69ab087 100644 --- a/main/file.c +++ b/main/file.c @@ -110,12 +110,12 @@ int ast_format_unregister(const char *name) AST_RWLIST_WRLOCK(&formats); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) { if (!strcasecmp(name, tmp->name)) { - AST_RWLIST_REMOVE_CURRENT(&formats, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_free(tmp); res = 0; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&formats); if (!res) diff --git a/main/frame.c b/main/frame.c index a0109fd67..50e9dabbc 100644 --- a/main/frame.c +++ b/main/frame.c @@ -452,7 +452,8 @@ struct ast_frame *ast_frdup(const struct ast_frame *f) AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) { if (out->mallocd_hdr_len >= len) { size_t mallocd_len = out->mallocd_hdr_len; - AST_LIST_REMOVE_CURRENT(&frames->list, frame_list); + + AST_LIST_REMOVE_CURRENT(frame_list); memset(out, 0, sizeof(*out)); out->mallocd_hdr_len = mallocd_len; buf = out; @@ -460,7 +461,7 @@ struct ast_frame *ast_frdup(const struct ast_frame *f) break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; } #endif diff --git a/main/image.c b/main/image.c index 5e6ce552c..91cdebaeb 100644 --- a/main/image.c +++ b/main/image.c @@ -65,11 +65,11 @@ void ast_image_unregister(struct ast_imager *img) AST_RWLIST_WRLOCK(&imagers); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&imagers, i, list) { if (i == img) { - AST_RWLIST_REMOVE_CURRENT(&imagers, list); + AST_RWLIST_REMOVE_CURRENT(list); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&imagers); if (i) ast_verb(2, "Unregistered format '%s' (%s)\n", img->name, img->desc); diff --git a/main/indications.c b/main/indications.c index 61f3328b5..ebebc682b 100644 --- a/main/indications.c +++ b/main/indications.c @@ -480,12 +480,12 @@ int ast_register_indication_country(struct ind_tone_zone *zone) if (tz == current_tonezone) current_tonezone = zone; /* Remove from the linked list */ - AST_RWLIST_REMOVE_CURRENT(&tone_zones, list); + AST_RWLIST_REMOVE_CURRENT(list); /* Finally free the zone itself */ free_zone(tz); break; } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; /* Add zone to the list */ AST_RWLIST_INSERT_TAIL(&tone_zones, zone, list); @@ -515,12 +515,12 @@ int ast_unregister_indication_country(const char *country) current_tonezone = NULL; } /* Remove from the list */ - AST_RWLIST_REMOVE_CURRENT(&tone_zones, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_verb(3, "Unregistered indication country '%s'\n", tz->country); free_zone(tz); res = 0; } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&tone_zones); return res; diff --git a/main/loader.c b/main/loader.c index d8567c840..e51505ea0 100644 --- a/main/loader.c +++ b/main/loader.c @@ -169,7 +169,7 @@ void ast_module_unregister(const struct ast_module_info *info) AST_LIST_LOCK(&module_list); AST_LIST_TRAVERSE_SAFE_BEGIN(&module_list, mod, entry) { if (mod->info == info) { - AST_LIST_REMOVE_CURRENT(&module_list, entry); + AST_LIST_REMOVE_CURRENT(entry); break; } } @@ -825,7 +825,7 @@ int load_modules(unsigned int preload_only) AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { if (!resource_name_match(order->resource, v->value)) { - AST_LIST_REMOVE_CURRENT(&load_order, entry); + AST_LIST_REMOVE_CURRENT(entry); ast_free(order->resource); ast_free(order); } @@ -849,7 +849,7 @@ int load_modules(unsigned int preload_only) switch (load_resource(order->resource, 1)) { case AST_MODULE_LOAD_SUCCESS: case AST_MODULE_LOAD_DECLINE: - AST_LIST_REMOVE_CURRENT(&load_order, entry); + AST_LIST_REMOVE_CURRENT(entry); ast_free(order->resource); ast_free(order); break; @@ -868,7 +868,7 @@ int load_modules(unsigned int preload_only) switch (load_resource(order->resource, 0)) { case AST_MODULE_LOAD_SUCCESS: case AST_MODULE_LOAD_DECLINE: - AST_LIST_REMOVE_CURRENT(&load_order, entry); + AST_LIST_REMOVE_CURRENT(entry); ast_free(order->resource); ast_free(order); break; @@ -961,7 +961,7 @@ int ast_loader_unregister(int (*v)(void)) AST_LIST_LOCK(&module_list); AST_LIST_TRAVERSE_SAFE_BEGIN(&updaters, cur, entry) { if (cur->updater == v) { - AST_LIST_REMOVE_CURRENT(&updaters, entry); + AST_LIST_REMOVE_CURRENT(entry); break; } } diff --git a/main/logger.c b/main/logger.c index 4f1685234..c1c8751e4 100644 --- a/main/logger.c +++ b/main/logger.c @@ -1166,12 +1166,12 @@ int ast_unregister_verbose(void (*v)(const char *string)) AST_RWLIST_WRLOCK(&verbosers); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&verbosers, cur, list) { if (cur->verboser == v) { - AST_RWLIST_REMOVE_CURRENT(&verbosers, list); + AST_RWLIST_REMOVE_CURRENT(list); free(cur); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&verbosers); return cur ? 0 : -1; diff --git a/main/manager.c b/main/manager.c index bc5ca1ba9..c329a9490 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2598,7 +2598,7 @@ static void purge_sessions(int n_max) AST_LIST_LOCK(&sessions); AST_LIST_TRAVERSE_SAFE_BEGIN(&sessions, s, list) { if (s->sessiontimeout && (now > s->sessiontimeout) && !s->inuse) { - AST_LIST_REMOVE_CURRENT(&sessions, list); + AST_LIST_REMOVE_CURRENT(list); ast_atomic_fetchadd_int(&num_sessions, -1); if (s->authenticated && (option_verbose > 1) && manager_displayconnects(s)) { ast_verb(2, "HTTP Manager '%s' timed out from %s\n", @@ -2609,7 +2609,7 @@ static void purge_sessions(int n_max) break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; AST_LIST_UNLOCK(&sessions); } @@ -2719,13 +2719,13 @@ int ast_manager_unregister(char *action) AST_RWLIST_WRLOCK(&actions); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&actions, cur, list) { if (!strcasecmp(action, cur->action)) { - AST_RWLIST_REMOVE_CURRENT(&actions, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_free(cur); ast_verb(2, "Manager unregistered action %s\n", action); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&actions); return 0; @@ -3476,7 +3476,7 @@ static int __init_manager(int reload) continue; } /* We do not need to keep this user so take them out of the list */ - AST_RWLIST_REMOVE_CURRENT(&users, list); + AST_RWLIST_REMOVE_CURRENT(list); /* Free their memory now */ if (user->secret) ast_free(user->secret); @@ -3490,7 +3490,7 @@ static int __init_manager(int reload) ast_free(user->write); ast_free(user); } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&users); diff --git a/main/pbx.c b/main/pbx.c index d740e91cd..d3949ecf1 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -1514,12 +1514,12 @@ int ast_custom_function_unregister(struct ast_custom_function *acf) AST_RWLIST_WRLOCK(&acf_root); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { if (cur == acf) { - AST_RWLIST_REMOVE_CURRENT(&acf_root, acflist); + AST_RWLIST_REMOVE_CURRENT(acflist); ast_verb(2, "Unregistered custom function %s\n", acf->name); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&acf_root); return acf ? 0 : -1; @@ -1547,11 +1547,11 @@ int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_m /* Store in alphabetical order */ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { if (strcasecmp(acf->name, cur->name) < 0) { - AST_RWLIST_INSERT_BEFORE_CURRENT(&acf_root, acf, acflist); + AST_RWLIST_INSERT_BEFORE_CURRENT(acf, acflist); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; if (!cur) AST_RWLIST_INSERT_TAIL(&acf_root, acf, acflist); @@ -2361,13 +2361,13 @@ static int ast_remove_hint(struct ast_exten *e) ast_free(cbprev); } hint->callbacks = NULL; - AST_RWLIST_REMOVE_CURRENT(&hints, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_free(hint); res = 0; break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; return res; } @@ -2935,13 +2935,13 @@ int ast_context_remove_switch2(struct ast_context *con, const char *sw, const ch if (!strcmp(i->name, sw) && !strcmp(i->data, data) && (!registrar || !strcmp(i->registrar, registrar))) { /* found, remove from list */ - AST_LIST_REMOVE_CURRENT(&con->alts, list); + AST_LIST_REMOVE_CURRENT(list); ast_free(i); /* free switch and return */ ret = 0; break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; ast_unlock_context(con); @@ -3136,11 +3136,11 @@ int ast_register_application2(const char *app, int (*execute)(struct ast_channel /* Store in alphabetical order */ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, cur, list) { if (strcasecmp(tmp->name, cur->name) < 0) { - AST_RWLIST_INSERT_BEFORE_CURRENT(&apps, tmp, list); + AST_RWLIST_INSERT_BEFORE_CURRENT(tmp, list); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; if (!cur) AST_RWLIST_INSERT_TAIL(&apps, tmp, list); @@ -4023,13 +4023,13 @@ int ast_unregister_application(const char *app) AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, tmp, list) { if (!strcasecmp(app, tmp->name)) { unreference_cached_app(tmp); - AST_RWLIST_REMOVE_CURRENT(&apps, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_verb(2, "Unregistered application '%s'\n", tmp->name); ast_free(tmp); break; } } - AST_RWLIST_TRAVERSE_SAFE_END + AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&apps); return tmp ? 0 : -1; diff --git a/main/sched.c b/main/sched.c index a68692db0..986badd16 100644 --- a/main/sched.c +++ b/main/sched.c @@ -177,11 +177,11 @@ static void schedule(struct sched_context *con, struct sched *s) AST_LIST_TRAVERSE_SAFE_BEGIN(&con->schedq, cur, list) { if (ast_tvcmp(s->when, cur->when) == -1) { - AST_LIST_INSERT_BEFORE_CURRENT(&con->schedq, s, list); + AST_LIST_INSERT_BEFORE_CURRENT(s, list); break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; if (!cur) AST_LIST_INSERT_TAIL(&con->schedq, s, list); @@ -278,13 +278,13 @@ int ast_sched_del(struct sched_context *con, int id) ast_mutex_lock(&con->lock); AST_LIST_TRAVERSE_SAFE_BEGIN(&con->schedq, s, list) { if (s->id == id) { - AST_LIST_REMOVE_CURRENT(&con->schedq, list); + AST_LIST_REMOVE_CURRENT(list); con->schedcnt--; sched_release(con, s); break; } } - AST_LIST_TRAVERSE_SAFE_END + AST_LIST_TRAVERSE_SAFE_END; #ifdef DUMP_SCHEDULER /* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */ diff --git a/main/srv.c b/main/srv.c index 898195dc1..e9c6d650d 100644 --- a/main/srv.c +++ b/main/srv.c @@ -132,7 +132,7 @@ static int srv_callback(void *context, unsigned char *answer, int len, unsigned if (current->priority <= entry->priority) continue; - AST_LIST_INSERT_BEFORE_CURRENT(&c->entries, entry, list); + AST_LIST_INSERT_BEFORE_CURRENT(entry, list); entry = NULL; break; } @@ -167,8 +167,7 @@ static void process_weights(struct srv_context *context) if (current->priority != cur_priority) break; - AST_LIST_REMOVE_CURRENT(&context->entries, list); - AST_LIST_INSERT_TAIL(&temp_list, current, list); + AST_LIST_MOVE_CURRENT(&temp_list, list); } AST_LIST_TRAVERSE_SAFE_END; @@ -190,8 +189,7 @@ static void process_weights(struct srv_context *context) if (current->weight < random_weight) continue; - AST_LIST_REMOVE_CURRENT(&temp_list, list); - AST_LIST_INSERT_TAIL(&newlist, current, list); + AST_LIST_MOVE_CURRENT(&newlist, list); } AST_LIST_TRAVERSE_SAFE_END; } diff --git a/main/translate.c b/main/translate.c index 09722a427..aa096436d 100644 --- a/main/translate.c +++ b/main/translate.c @@ -654,7 +654,7 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod) if ((u->srcfmt == t->srcfmt) && (u->dstfmt == t->dstfmt) && (u->cost > t->cost)) { - AST_RWLIST_INSERT_BEFORE_CURRENT(&translators, t, list); + AST_RWLIST_INSERT_BEFORE_CURRENT(t, list); t = NULL; } } @@ -682,7 +682,7 @@ int ast_unregister_translator(struct ast_translator *t) AST_RWLIST_WRLOCK(&translators); AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { if (u == t) { - AST_RWLIST_REMOVE_CURRENT(&translators, list); + AST_RWLIST_REMOVE_CURRENT(list); ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt)); found = 1; break; |