summaryrefslogtreecommitdiff
path: root/main/pbx.c
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2007-01-06 00:28:16 +0000
committerJason Parker <jparker@digium.com>2007-01-06 00:28:16 +0000
commit5abda34cd997d0cff3c8f72e1c8a61daa3c124aa (patch)
treeecfc8c3149057447003a8f3320f7c9e4ddba703d /main/pbx.c
parent37182c873e93244ae1181130be60e0de2b209ed4 (diff)
Merged revisions 49742 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49742 | qwell | 2007-01-05 18:24:38 -0600 (Fri, 05 Jan 2007) | 7 lines Save 1 whopping byte of allocated memory! This looks like it may have been a chicken/egg scenario.. You had to call a cleanup func, because everything was allocated. Then since you had to call a cleanup func, you were forced to allocate - ie; strdup(""). ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49743 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/pbx.c')
-rw-r--r--main/pbx.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/main/pbx.c b/main/pbx.c
index e45495e5b..151a791a4 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4556,10 +4556,6 @@ static int ext_strncpy(char *dst, const char *src, int len)
return count;
}
-static void null_datad(void *foo)
-{
-}
-
/*! \brief add the extension in the priority chain.
* returns 0 on success, -1 on failure
*/
@@ -4581,7 +4577,8 @@ static int add_pri(struct ast_context *con, struct ast_exten *tmp,
replacement? If so, replace, otherwise, bonk. */
if (!replace) {
ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name);
- tmp->datad(tmp->data);
+ if (tmp->datad)
+ tmp->datad(tmp->data);
free(tmp);
return -1;
}
@@ -4599,7 +4596,8 @@ static int add_pri(struct ast_context *con, struct ast_exten *tmp,
if (tmp->priority == PRIORITY_HINT)
ast_change_hint(e,tmp);
/* Destroy the old one */
- e->datad(e->data);
+ if (e->datad)
+ e->datad(e->data);
free(e);
} else { /* Slip ourselves in just before e */
tmp->peer = e;
@@ -4683,8 +4681,6 @@ int ast_add_extension2(struct ast_context *con,
length ++; /* just the '\0' */
/* Be optimistic: Build the extension structure first */
- if (datad == NULL)
- datad = null_datad;
if (!(tmp = ast_calloc(1, length)))
return -1;