mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 00:04:53 +00:00
more code restructuring
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@25746 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
47
pbx.c
47
pbx.c
@@ -4766,35 +4766,37 @@ static void destroy_exten(struct ast_exten *e)
|
||||
void __ast_context_destroy(struct ast_context *con, const char *registrar)
|
||||
{
|
||||
struct ast_context *tmp, *tmpl=NULL;
|
||||
struct ast_include *tmpi, *tmpil= NULL;
|
||||
struct ast_include *tmpi;
|
||||
struct ast_sw *sw;
|
||||
struct ast_exten *e, *el, *en;
|
||||
struct ast_ignorepat *ipi, *ipl = NULL;
|
||||
struct ast_ignorepat *ipi;
|
||||
|
||||
ast_mutex_lock(&conlock);
|
||||
tmp = contexts;
|
||||
while(tmp) {
|
||||
if (((tmp->name && con && con->name && !strcasecmp(tmp->name, con->name)) || !con) &&
|
||||
(!registrar || !strcasecmp(registrar, tmp->registrar))) {
|
||||
/* Okay, let's lock the structure to be sure nobody else
|
||||
is searching through it. */
|
||||
for (tmp = contexts; tmp; ) {
|
||||
struct ast_context *next; /* next starting point */
|
||||
for (; tmp; tmpl = tmp, tmp = tmp->next) {
|
||||
if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) &&
|
||||
(!con || !strcasecmp(tmp->name, con->name)) )
|
||||
break; /* found it */
|
||||
}
|
||||
if (!tmp) /* not found, we are done */
|
||||
break;
|
||||
ast_mutex_lock(&tmp->lock);
|
||||
next = tmp->next;
|
||||
if (tmpl)
|
||||
tmpl->next = tmp->next;
|
||||
tmpl->next = next;
|
||||
else
|
||||
contexts = tmp->next;
|
||||
contexts = next;
|
||||
/* Okay, now we're safe to let it go -- in a sense, we were
|
||||
ready to let it go as soon as we locked it. */
|
||||
ast_mutex_unlock(&tmp->lock);
|
||||
for (tmpi = tmp->includes; tmpi; ) {
|
||||
/* Free includes */
|
||||
tmpil = tmpi;
|
||||
for (tmpi = tmp->includes; tmpi; ) { /* Free includes */
|
||||
struct ast_include *tmpil = tmpi;
|
||||
tmpi = tmpi->next;
|
||||
free(tmpil);
|
||||
}
|
||||
for (ipi = tmp->ignorepats; ipi; ) {
|
||||
/* Free ignorepats */
|
||||
ipl = ipi;
|
||||
for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */
|
||||
struct ast_ignorepat *ipl = ipi;
|
||||
ipi = ipi->next;
|
||||
free(ipl);
|
||||
}
|
||||
@@ -4812,17 +4814,8 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar)
|
||||
}
|
||||
ast_mutex_destroy(&tmp->lock);
|
||||
free(tmp);
|
||||
if (!con) {
|
||||
/* Might need to get another one -- restart */
|
||||
tmp = contexts;
|
||||
tmpl = NULL;
|
||||
tmpil = NULL;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
tmpl = tmp;
|
||||
tmp = tmp->next;
|
||||
/* if we have a specific match, we are done, otherwise continue */
|
||||
tmp = con ? NULL : next;
|
||||
}
|
||||
ast_mutex_unlock(&conlock);
|
||||
}
|
||||
|
Reference in New Issue
Block a user