diff options
author | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-06 00:24:38 +0000 |
---|---|---|
committer | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-06 00:24:38 +0000 |
commit | f008966b3cea1a9d8fb0115d7829ccc6688fde17 (patch) | |
tree | 6552f58f576d71c5e396acee7943fa4739f6ce32 /main/pbx.c | |
parent | 3adb451f3c31f53393c97879f79870b11c227512 (diff) |
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: http://svn.digium.com/svn/asterisk/branches/1.4@49742 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/main/pbx.c b/main/pbx.c index d981a994c..0c3c88472 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -4591,10 +4591,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 */ @@ -4616,7 +4612,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; } @@ -4634,7 +4631,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; @@ -4718,8 +4716,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; |