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/branches/1.4@49742 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Jason Parker 19 years ago
parent fb05d85ac2
commit 9e621e99a5

@ -4591,10 +4591,6 @@ static int ext_strncpy(char *dst, const char *src, int len)
return count; return count;
} }
static void null_datad(void *foo)
{
}
/*! \brief add the extension in the priority chain. /*! \brief add the extension in the priority chain.
* returns 0 on success, -1 on failure * returns 0 on success, -1 on failure
*/ */
@ -4616,6 +4612,7 @@ static int add_pri(struct ast_context *con, struct ast_exten *tmp,
replacement? If so, replace, otherwise, bonk. */ replacement? If so, replace, otherwise, bonk. */
if (!replace) { 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); ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name);
if (tmp->datad)
tmp->datad(tmp->data); tmp->datad(tmp->data);
free(tmp); free(tmp);
return -1; return -1;
@ -4634,6 +4631,7 @@ static int add_pri(struct ast_context *con, struct ast_exten *tmp,
if (tmp->priority == PRIORITY_HINT) if (tmp->priority == PRIORITY_HINT)
ast_change_hint(e,tmp); ast_change_hint(e,tmp);
/* Destroy the old one */ /* Destroy the old one */
if (e->datad)
e->datad(e->data); e->datad(e->data);
free(e); free(e);
} else { /* Slip ourselves in just before e */ } else { /* Slip ourselves in just before e */
@ -4718,8 +4716,6 @@ int ast_add_extension2(struct ast_context *con,
length ++; /* just the '\0' */ length ++; /* just the '\0' */
/* Be optimistic: Build the extension structure first */ /* Be optimistic: Build the extension structure first */
if (datad == NULL)
datad = null_datad;
if (!(tmp = ast_calloc(1, length))) if (!(tmp = ast_calloc(1, length)))
return -1; return -1;

@ -2409,7 +2409,7 @@ static void pbx_load_users(void)
} }
if (!ast_strlen_zero(iface)) { if (!ast_strlen_zero(iface)) {
/* Add hint */ /* Add hint */
ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, strdup(""), ast_free, registrar); ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, NULL, NULL, registrar);
/* If voicemail, use "stdexten" else use plain old dial */ /* If voicemail, use "stdexten" else use plain old dial */
if (hasvoicemail) { if (hasvoicemail) {
snprintf(tmp, sizeof(tmp), "stdexten|%s|${HINT}", cat); snprintf(tmp, sizeof(tmp), "stdexten|%s|${HINT}", cat);

@ -2277,7 +2277,7 @@ static int load_config(void)
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con); ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
return -1; return -1;
} }
res = ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), ast_free, registrar); res = ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, NULL, NULL, registrar);
if (parkaddhints) if (parkaddhints)
park_add_hints(parking_con, parking_start, parking_stop); park_add_hints(parking_con, parking_start, parking_stop);
if (!res) if (!res)

Loading…
Cancel
Save