Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 22327) +++ apps/app_voicemail.c (working copy) @@ -245,10 +245,10 @@ }; struct vm_zone { + AST_LIST_ENTRY(vm_zone) list; char name[80]; char timezone[80]; char msg_format[512]; - struct vm_zone *next; }; struct vm_state { @@ -388,8 +388,7 @@ static char *app4 = "VMAuthenticate"; static AST_LIST_HEAD_STATIC(users, ast_vm_user); -struct vm_zone *zones = NULL; -struct vm_zone *zonesl = NULL; +static AST_LIST_HEAD_NOLOCK_STATIC(zones, vm_zone); static int maxsilence; static int maxmsg; static int silencethreshold = 128; @@ -1655,9 +1654,10 @@ /* Does this user have a timezone specified? */ if (!ast_strlen_zero(vmu->zonetag)) { /* Find the zone in the list */ - for (z = zones; z ; z = z->next) + AST_LIST_TRAVERSE(&zones, z, list) { if (!strcmp(z->name, vmu->zonetag)) break; + } } ast_localtime(&t, tm, z ? z->timezone : NULL); return tm; @@ -3592,7 +3592,7 @@ if (!ast_strlen_zero(vmu->zonetag)) { /* Find the zone in the list */ struct vm_zone *z; - for (z = zones; z; z = z->next) { + AST_LIST_TRAVERSE(&zones, z, list) { if (!strcmp(z->name, vmu->zonetag)) { the_zone = z; break; @@ -5858,16 +5858,15 @@ static int handle_show_voicemail_zones(int fd, int argc, char *argv[]) { - struct vm_zone *zone = zones; + struct vm_zone *zone; char *output_format = "%-15s %-20s %-45s\n"; if (argc != 3) return RESULT_SHOWUSAGE; - if (zone) { + if (AST_LIST_FIRST(&zones)) { ast_cli(fd, output_format, "Zone", "Timezone", "Message Format"); - while (zone) { + AST_LIST_TRAVERSE(&zones, zone, list) { ast_cli(fd, output_format, zone->name, zone->timezone, zone->msg_format); - zone = zone->next; } } else { ast_cli(fd, "There are no voicemail zones currently defined\n"); @@ -5913,7 +5912,7 @@ static int load_config(void) { struct ast_vm_user *cur; - struct vm_zone *zcur, *zl; + struct vm_zone *zcur; struct ast_config *cfg; char *cat; struct ast_variable *var; @@ -5951,20 +5950,15 @@ cfg = ast_config_load(VOICEMAIL_CONFIG); AST_LIST_LOCK(&users); - AST_LIST_TRAVERSE_SAFE_BEGIN(&users, cur, list) { - AST_LIST_REMOVE_CURRENT(&users, list); + while (!AST_LIST_EMPTY(&users)) { + cur = AST_LIST_REMOVE_HEAD(&users, list); ast_set_flag(cur, VM_ALLOCED); free_user(cur); } - AST_LIST_TRAVERSE_SAFE_END; - zcur = zones; - while (zcur) { - zl = zcur; - zcur = zcur->next; - free_zone(zl); + while (!AST_LIST_EMPTY(&zones)) { + zcur = AST_LIST_REMOVE_HEAD(&zones, list); + free_zone(zcur); } - zones = NULL; - zonesl = NULL; memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd)); if (cfg) { @@ -6232,14 +6226,7 @@ ast_copy_string(z->name, var->name, sizeof(z->name)); ast_copy_string(z->timezone, timezone, sizeof(z->timezone)); ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format)); - z->next = NULL; - if (zones) { - zonesl->next = z; - zonesl = z; - } else { - zones = z; - zonesl = z; - } + AST_LIST_INSERT_HEAD(&zones, z, list); } else { ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno); free(z);