aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/acl.c6
-rw-r--r--main/app.c10
-rw-r--r--main/asterisk.c16
-rw-r--r--main/autoservice.c4
-rw-r--r--main/callerid.c2
-rw-r--r--main/cdr.c11
-rw-r--r--main/channel.c46
-rw-r--r--main/chanvars.c2
-rw-r--r--main/cli.c26
-rw-r--r--main/config.c23
-rw-r--r--main/db.c2
-rw-r--r--main/devicestate.c4
-rw-r--r--main/dial.c10
-rw-r--r--main/dlfcn.c48
-rw-r--r--main/dnsmgr.c2
-rw-r--r--main/dsp.c2
-rw-r--r--main/enum.c12
-rw-r--r--main/event.c12
-rw-r--r--main/file.c32
-rw-r--r--main/fixedjitterbuf.c6
-rw-r--r--main/frame.c18
-rw-r--r--main/http.c28
-rw-r--r--main/indications.c26
-rw-r--r--main/io.c14
-rw-r--r--main/jitterbuf.c4
-rw-r--r--main/loader.c28
-rw-r--r--main/manager.c40
-rw-r--r--main/netsock.c6
-rw-r--r--main/pbx.c62
-rw-r--r--main/rtp.c16
-rw-r--r--main/say.c14
-rw-r--r--main/sched.c8
-rw-r--r--main/strcompat.c4
-rw-r--r--main/tdd.c6
-rw-r--r--main/threadstorage.c2
-rw-r--r--main/translate.c4
-rw-r--r--main/udptl.c8
-rw-r--r--main/utils.c2
38 files changed, 283 insertions, 283 deletions
diff --git a/main/acl.c b/main/acl.c
index 55654f714..3a88c3c1a 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -90,7 +90,7 @@ void ast_free_ha(struct ast_ha *ha)
while (ha) {
hal = ha;
ha = ha->next;
- free(hal);
+ ast_free(hal);
}
}
@@ -174,14 +174,14 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int
ast_log(LOG_WARNING, "%s is not a valid netmask\n", nm);
if (error)
*error = 1;
- free(ha);
+ ast_free(ha);
return ret;
}
if (!inet_aton(tmp, &ha->netaddr)) {
ast_log(LOG_WARNING, "%s is not a valid IP\n", tmp);
if (error)
*error = 1;
- free(ha);
+ ast_free(ha);
return ret;
}
ha->netaddr.s_addr &= ha->netmask.s_addr;
diff --git a/main/app.c b/main/app.c
index 32e36e9df..b3fd264f1 100644
--- a/main/app.c
+++ b/main/app.c
@@ -306,7 +306,7 @@ static void linear_release(struct ast_channel *chan, void *params)
}
if (ls->autoclose)
close(ls->fd);
- free(params);
+ ast_free(params);
}
static int linear_generator(struct ast_channel *chan, void *data, int len, int samples)
@@ -349,7 +349,7 @@ static void *linear_alloc(struct ast_channel *chan, void *params)
ls->origwfmt = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);
- free(ls);
+ ast_free(ls);
ls = params = NULL;
}
}
@@ -844,7 +844,7 @@ int ast_app_group_set_channel(struct ast_channel *chan, const char *data)
break;
}
- if (!gi && (gi = calloc(1, len))) {
+ if (!gi && (gi = ast_calloc(1, len))) {
gi->chan = chan;
gi->group = (char *) gi + sizeof(*gi);
strcpy(gi->group, group);
@@ -927,7 +927,7 @@ int ast_app_group_discard(struct ast_channel *chan)
AST_LIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) {
if (gi->chan == chan) {
AST_LIST_REMOVE_CURRENT(&groups, list);
- free(gi);
+ ast_free(gi);
}
}
AST_LIST_TRAVERSE_SAFE_END
@@ -1378,7 +1378,7 @@ char *ast_read_textfile(const char *filename)
output[res] = '\0';
} else {
ast_log(LOG_WARNING, "Short read of %s (%d of %d): %s\n", filename, res, count - 1, strerror(errno));
- free(output);
+ ast_free(output);
output = NULL;
}
}
diff --git a/main/asterisk.c b/main/asterisk.c
index 18a121339..48a90ae82 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -294,7 +294,7 @@ void ast_unregister_file_version(const char *file)
AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_UNLOCK(&file_versions);
if (find)
- free(find);
+ ast_free(find);
}
struct thread_list_t {
@@ -336,8 +336,8 @@ void ast_unregister_thread(void *id)
AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_UNLOCK(&thread_list);
if (x) {
- free(x->name);
- free(x);
+ ast_free(x->name);
+ ast_free(x);
}
}
@@ -2036,7 +2036,7 @@ static int ast_cli_display_match_list(char **matches, int len, int max)
/* Don't print dupes */
if ( (matches[idx+1] != NULL && strcmp(matches[idx], matches[idx+1]) == 0 ) ) {
i--;
- free(matches[idx]);
+ ast_free(matches[idx]);
matches[idx] = NULL;
continue;
}
@@ -2044,7 +2044,7 @@ static int ast_cli_display_match_list(char **matches, int len, int max)
numoutput++;
numoutputline++;
fprintf(stdout, "%-*s ", max, matches[idx]);
- free(matches[idx]);
+ ast_free(matches[idx]);
matches[idx] = NULL;
}
if (numoutputline > 0)
@@ -2113,7 +2113,7 @@ static char *cli_complete(EditLine *el, int ch)
mbuf[mlen] = '\0';
matches = ast_el_strtoarr(mbuf);
- free(mbuf);
+ ast_free(mbuf);
} else
matches = (char **) NULL;
} else {
@@ -2159,8 +2159,8 @@ static char *cli_complete(EditLine *el, int ch)
}
}
for (i = 0; matches[i]; i++)
- free(matches[i]);
- free(matches);
+ ast_free(matches[i]);
+ ast_free(matches);
}
return (char *)(long)retval;
diff --git a/main/autoservice.c b/main/autoservice.c
index 29b915daa..9ce49ac82 100644
--- a/main/autoservice.c
+++ b/main/autoservice.c
@@ -117,7 +117,7 @@ int ast_autoservice_start(struct ast_channel *chan)
/* There will only be a single member in the list at this point,
the one we just added. */
AST_RWLIST_REMOVE(&aslist, as, list);
- free(as);
+ ast_free(as);
res = -1;
} else
pthread_kill(asthread, SIGURG);
@@ -136,7 +136,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) {
if (as->chan == chan) {
AST_RWLIST_REMOVE_CURRENT(&aslist, list);
- free(as);
+ ast_free(as);
if (!chan->_softhangup)
res = 0;
break;
diff --git a/main/callerid.c b/main/callerid.c
index 74b8d9200..c870a462f 100644
--- a/main/callerid.c
+++ b/main/callerid.c
@@ -683,7 +683,7 @@ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, int
void callerid_free(struct callerid_state *cid)
{
- free(cid);
+ ast_free(cid);
}
static int callerid_genmsg(char *msg, int size, const char *number, const char *name, int flags)
diff --git a/main/cdr.c b/main/cdr.c
index 7e3ab5bf9..76b5cfc1c 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -157,7 +157,7 @@ void ast_cdr_unregister(const char *name)
AST_LIST_REMOVE_CURRENT(&be_list, list);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Unregistered '%s' CDR backend\n", name);
- free(i);
+ ast_free(i);
break;
}
}
@@ -440,7 +440,7 @@ void ast_cdr_free(struct ast_cdr *cdr)
ast_log(LOG_NOTICE, "CDR on channel '%s' lacks start\n", chan);
ast_cdr_free_vars(cdr, 0);
- free(cdr);
+ ast_free(cdr);
cdr = next;
}
}
@@ -452,14 +452,15 @@ void ast_cdr_discard(struct ast_cdr *cdr)
struct ast_cdr *next = cdr->next;
ast_cdr_free_vars(cdr, 0);
- free(cdr);
+ ast_free(cdr);
cdr = next;
}
}
struct ast_cdr *ast_cdr_alloc(void)
{
- struct ast_cdr *x = ast_calloc(1, sizeof(struct ast_cdr));
+ struct ast_cdr *x;
+ x = ast_calloc(1, sizeof(*x));
if (!x)
ast_log(LOG_ERROR,"Allocation Failure for a CDR!\n");
return x;
@@ -1024,7 +1025,7 @@ static void *do_batch_backend_process(void *data)
ast_cdr_free(batchitem->cdr);
processeditem = batchitem;
batchitem = batchitem->next;
- free(processeditem);
+ ast_free(processeditem);
}
return NULL;
diff --git a/main/channel.c b/main/channel.c
index c0aa2326e..64ac4e583 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -458,7 +458,7 @@ void ast_channel_unregister(const struct ast_channel_tech *tech)
AST_LIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) {
if (chan->tech == tech) {
AST_LIST_REMOVE_CURRENT(&backends, list);
- free(chan);
+ ast_free(chan);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Unregistered channel type '%s'\n", tech->type);
break;
@@ -648,13 +648,13 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
if (!(tmp->sched = sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
- free(tmp);
+ ast_free(tmp);
return NULL;
}
if ((ast_string_field_init(tmp, 128))) {
sched_context_destroy(tmp->sched);
- free(tmp);
+ ast_free(tmp);
return NULL;
}
@@ -681,7 +681,7 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
if (pipe(tmp->alertpipe)) {
ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n");
ast_string_field_free_pools(tmp);
- free(tmp);
+ ast_free(tmp);
return NULL;
} else {
flags = fcntl(tmp->alertpipe[0], F_GETFL);
@@ -1057,15 +1057,15 @@ int ast_safe_sleep(struct ast_channel *chan, int ms)
static void free_cid(struct ast_callerid *cid)
{
if (cid->cid_dnid)
- free(cid->cid_dnid);
+ ast_free(cid->cid_dnid);
if (cid->cid_num)
- free(cid->cid_num);
+ ast_free(cid->cid_num);
if (cid->cid_name)
- free(cid->cid_name);
+ ast_free(cid->cid_name);
if (cid->cid_ani)
- free(cid->cid_ani);
+ ast_free(cid->cid_ani);
if (cid->cid_rdnis)
- free(cid->cid_rdnis);
+ ast_free(cid->cid_rdnis);
cid->cid_dnid = cid->cid_num = cid->cid_name = cid->cid_ani = cid->cid_rdnis = NULL;
}
@@ -1092,7 +1092,7 @@ void ast_channel_free(struct ast_channel *chan)
ast_channel_unlock(chan);
if (chan->tech_pvt) {
ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name);
- free(chan->tech_pvt);
+ ast_free(chan->tech_pvt);
}
if (chan->sched)
@@ -1149,7 +1149,7 @@ void ast_channel_free(struct ast_channel *chan)
ast_jb_destroy(chan);
ast_string_field_free_pools(chan);
- free(chan);
+ ast_free(chan);
AST_LIST_UNLOCK(&channels);
ast_device_state_changed_literal(name);
@@ -1160,13 +1160,13 @@ struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_inf
struct ast_datastore *datastore = NULL;
/* Make sure we at least have type so we can identify this */
- if (info == NULL) {
+ if (!info) {
return NULL;
}
/* Allocate memory for datastore and clear it */
datastore = ast_calloc(1, sizeof(*datastore));
- if (datastore == NULL) {
+ if (!datastore) {
return NULL;
}
@@ -1194,7 +1194,7 @@ int ast_channel_datastore_free(struct ast_datastore *datastore)
}
/* Finally free memory used by ourselves */
- free(datastore);
+ ast_free(datastore);
return res;
}
@@ -1332,7 +1332,7 @@ static void spy_cleanup(struct ast_channel *chan)
ast_translator_free_path(chan->spies->read_translator.path);
if (chan->spies->write_translator.path)
ast_translator_free_path(chan->spies->write_translator.path);
- free(chan->spies);
+ ast_free(chan->spies);
chan->spies = NULL;
return;
}
@@ -2522,7 +2522,7 @@ int ast_recvchar(struct ast_channel *chan, int timeout)
if (buf == NULL)
return -1; /* error or timeout */
c = *(unsigned char *)buf;
- free(buf);
+ ast_free(buf);
return c;
}
@@ -3702,17 +3702,17 @@ void ast_set_callerid(struct ast_channel *chan, const char *callerid, const char
{
if (callerid) {
if (chan->cid.cid_num)
- free(chan->cid.cid_num);
+ ast_free(chan->cid.cid_num);
chan->cid.cid_num = ast_strdup(callerid);
}
if (calleridname) {
if (chan->cid.cid_name)
- free(chan->cid.cid_name);
+ ast_free(chan->cid.cid_name);
chan->cid.cid_name = ast_strdup(calleridname);
}
if (ani) {
if (chan->cid.cid_ani)
- free(chan->cid.cid_ani);
+ ast_free(chan->cid.cid_ani);
chan->cid.cid_ani = ast_strdup(ani);
}
if (chan->cdr)
@@ -4262,7 +4262,7 @@ static void tonepair_release(struct ast_channel *chan, void *params)
if (chan)
ast_set_write_format(chan, ts->origwfmt);
- free(ts);
+ ast_free(ts);
}
static void *tonepair_alloc(struct ast_channel *chan, void *params)
@@ -4670,7 +4670,7 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
- free(state);
+ ast_free(state);
return NULL;
}
@@ -4695,7 +4695,7 @@ void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_sil
if (ast_set_write_format(chan, state->old_write_format) < 0)
ast_log(LOG_ERROR, "Could not return write format to its original state\n");
- free(state);
+ ast_free(state);
}
@@ -4925,6 +4925,6 @@ void ast_channel_whisper_stop(struct ast_channel *chan)
ast_set_write_format(chan, chan->whisper->original_format);
ast_slinfactory_destroy(&chan->whisper->sf);
ast_mutex_destroy(&chan->whisper->lock);
- free(chan->whisper);
+ ast_free(chan->whisper);
chan->whisper = NULL;
}
diff --git a/main/chanvars.c b/main/chanvars.c
index 7e617c1fb..858933c92 100644
--- a/main/chanvars.c
+++ b/main/chanvars.c
@@ -56,7 +56,7 @@ struct ast_var_t *ast_var_assign(const char *name, const char *value)
void ast_var_delete(struct ast_var_t *var)
{
if (var)
- free(var);
+ ast_free(var);
}
const char *ast_var_name(const struct ast_var_t *var)
diff --git a/main/cli.c b/main/cli.c
index 91ab41f59..a3a2532c4 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -626,19 +626,19 @@ static int handle_commandmatchesarray(int fd, int argc, char *argv[])
obuf = buf;
if (!(buf = ast_realloc(obuf, buflen)))
/* Memory allocation failure... Just free old buffer and be done */
- free(obuf);
+ ast_free(obuf);
}
if (buf)
len += sprintf( buf + len, "%s ", matches[x]);
- free(matches[x]);
+ ast_free(matches[x]);
matches[x] = NULL;
}
- free(matches);
+ ast_free(matches);
}
if (buf) {
ast_cli(fd, "%s%s",buf, AST_CLI_COMPLETE_EOF);
- free(buf);
+ ast_free(buf);
} else
ast_cli(fd, "NULL\n");
@@ -670,7 +670,7 @@ static int handle_commandcomplete(int fd, int argc, char *argv[])
buf = __ast_cli_generator(argv[2], argv[3], atoi(argv[4]), 0);
if (buf) {
ast_cli(fd, buf);
- free(buf);
+ ast_free(buf);
} else
ast_cli(fd, "NULL\n");
return RESULT_SUCCESS;
@@ -1247,12 +1247,12 @@ static int __ast_cli_unregister(struct ast_cli_entry *e, struct ast_cli_entry *e
AST_LIST_LOCK(&helpers);
AST_LIST_REMOVE(&helpers, e, list);
AST_LIST_UNLOCK(&helpers);
- free(e->_full_cmd);
+ ast_free(e->_full_cmd);
e->_full_cmd = NULL;
if (e->new_handler) {
/* this is a new-style entry. Reset fields and free memory. */
bzero((char **)(e->cmda), sizeof(e->cmda));
- free(e->command);
+ ast_free(e->command);
e->command = NULL;
e->usage = NULL;
}
@@ -1291,7 +1291,7 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed)
if (find_cli(e->cmda, 1)) {
ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", e->_full_cmd);
- free(e->_full_cmd);
+ ast_free(e->_full_cmd);
e->_full_cmd = NULL;
goto done;
}
@@ -1525,11 +1525,11 @@ int ast_cli_generatornummatches(const char *text, const char *word)
if (!oldbuf || strcmp(buf,oldbuf))
matches++;
if (oldbuf)
- free(oldbuf);
+ ast_free(oldbuf);
oldbuf = buf;
}
if (oldbuf)
- free(oldbuf);
+ ast_free(oldbuf);
return matches;
}
@@ -1648,7 +1648,7 @@ static char *__ast_cli_generator(const char *text, const char *word, int state,
*/
if (matchnum > state)
break;
- free(ret);
+ ast_free(ret);
ret = NULL;
} else if (ast_strlen_zero(e->cmda[dst])) {
/*
@@ -1671,7 +1671,7 @@ static char *__ast_cli_generator(const char *text, const char *word, int state,
}
if (lock)
AST_LIST_UNLOCK(&helpers);
- free(dup);
+ ast_free(dup);
return ret;
}
@@ -1745,6 +1745,6 @@ int ast_cli_command(int fd, const char *s)
}
ast_atomic_fetchadd_int(&e->inuse, -1);
done:
- free(dup);
+ ast_free(dup);
return 0;
}
diff --git a/main/config.c b/main/config.c
index 50979b431..54e899761 100644
--- a/main/config.c
+++ b/main/config.c
@@ -140,7 +140,8 @@ static void CB_RESET(char **comment_buffer, char **lline_buffer)
static struct ast_comment *ALLOC_COMMENT(const char *buffer)
{
- struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1);
+ struct ast_comment *x;
+ x = ast_calloc(1, sizeof(*x)+strlen(buffer)+1);
strcpy(x->cmt, buffer);
return x;
}
@@ -215,7 +216,7 @@ void ast_variables_destroy(struct ast_variable *v)
while (v) {
vn = v;
v = v->next;
- free(vn);
+ ast_free(vn);
}
}
@@ -344,7 +345,7 @@ void ast_category_append(struct ast_config *config, struct ast_category *categor
void ast_category_destroy(struct ast_category *cat)
{
ast_variables_destroy(cat->root);
- free(cat);
+ ast_free(cat);
}
static struct ast_category *next_available_category(struct ast_category *cat)
@@ -522,7 +523,7 @@ int ast_category_delete(struct ast_config *cfg, const char *category)
if (cat == cfg->last)
cfg->last = NULL;
}
- free(cat);
+ ast_free(cat);
return 0;
}
prev = cat;
@@ -543,7 +544,7 @@ int ast_category_delete(struct ast_config *cfg, const char *category)
if (cat == cfg->last)
cfg->last = NULL;
}
- free(cat);
+ ast_free(cat);
return 0;
}
prev = cat;
@@ -564,9 +565,9 @@ void ast_config_destroy(struct ast_config *cfg)
ast_variables_destroy(cat->root);
catn = cat;
cat = cat->next;
- free(catn);
+ ast_free(catn);
}
- free(cfg);
+ ast_free(cfg);
}
struct ast_category *ast_config_get_current_category(const struct ast_config *cfg)
@@ -934,8 +935,8 @@ static struct ast_config *config_text_file_load(const char *database, const char
#endif
if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
- free(comment_buffer);
- free(lline_buffer);
+ ast_free(comment_buffer);
+ ast_free(lline_buffer);
comment_buffer = NULL;
lline_buffer = NULL;
comment_buffer_size = 0;
@@ -1046,7 +1047,7 @@ static void clear_config_maps(void)
while (config_maps) {
map = config_maps;
config_maps = config_maps->next;
- free(map);
+ ast_free(map);
}
ast_mutex_unlock(&config_lock);
@@ -1345,7 +1346,7 @@ struct ast_variable *ast_load_realtime(const char *family, ...)
/* Eliminate blank entries */
for (cur = res; cur; cur = cur->next) {
if (freeme) {
- free(freeme);
+ ast_free(freeme);
freeme = NULL;
}
diff --git a/main/db.c b/main/db.c
index 34041cba2..b7182e60c 100644
--- a/main/db.c
+++ b/main/db.c
@@ -466,7 +466,7 @@ void ast_db_freetree(struct ast_db_entry *dbe)
while (dbe) {
last = dbe;
dbe = dbe->next;
- free(last);
+ ast_free(last);
}
}
diff --git a/main/devicestate.c b/main/devicestate.c
index f8e1a337a..d682602d6 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -339,7 +339,7 @@ int ast_devstate_prov_del(const char *label)
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&devstate_provs, devcb, list) {
if (!strcasecmp(devcb->label, label)) {
AST_RWLIST_REMOVE_CURRENT(&devstate_provs, list);
- free(devcb);
+ ast_free(devcb);
res = 0;
break;
}
@@ -463,7 +463,7 @@ static void *do_devstate_changes(void *data)
while ((current = next)) {
next = AST_LIST_NEXT(current, list);
do_state_change(current->device);
- free(current);
+ ast_free(current);
}
}
diff --git a/main/dial.c b/main/dial.c
index 507eefcc3..8b804fdbb 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -115,10 +115,10 @@ static int answer_exec_disable(void *data)
/* If arguments are present, free them too */
if (answer_exec->args)
- free(answer_exec->args);
+ ast_free(answer_exec->args);
/* This is simple - just free the structure */
- free(answer_exec);
+ ast_free(answer_exec);
return 0;
}
@@ -133,7 +133,7 @@ static int music_disable(void *data)
if (!data)
return -1;
- free(data);
+ ast_free(data);
return 0;
}
@@ -707,7 +707,7 @@ int ast_dial_destroy(struct ast_dial *dial)
channel->owner = NULL;
}
/* Free structure */
- free(channel);
+ ast_free(channel);
}
/* Disable any enabled options globally */
@@ -720,7 +720,7 @@ int ast_dial_destroy(struct ast_dial *dial)
}
/* Free structure */
- free(dial);
+ ast_free(dial);
return 0;
}
diff --git a/main/dlfcn.c b/main/dlfcn.c
index cc6fe40f9..9a68b5c19 100644
--- a/main/dlfcn.c
+++ b/main/dlfcn.c
@@ -287,7 +287,7 @@ static const char *searchList()
if (!buf)
{
buf_size = strlen(ldlp) + strlen(dyldlp) + strlen(stdpath) + 4;
- buf = malloc(buf_size);
+ buf = ast_malloc(buf_size);
snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""),
stdpath, '\0');
}
@@ -309,18 +309,18 @@ static const char *getSearchPath(int i)
}
if (!path)
{
- path = (char **)calloc(MAX_SEARCH_PATHS, sizeof(char **));
+ path = ast_calloc(MAX_SEARCH_PATHS, sizeof(char **));
}
if (!list && !end)
list = searchList();
if (i >= (numsize))
{
debug("Increasing size for long PATH");
- tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **));
+ tmp = ast_calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **));
if (tmp)
{
memcpy(tmp, path, sizeof(char **) * numsize);
- free(path);
+ ast_free(path);
path = tmp;
numsize += MAX_SEARCH_PATHS;
}
@@ -434,7 +434,7 @@ static struct dlstatus *allocStatus()
dls = dls->next;
if (!dls)
#endif
- dls = malloc(sizeof(*dls));
+ dls = ast_malloc(sizeof(*dls));
dls->flags = 0;
return dls;
}
@@ -551,7 +551,7 @@ static inline const char *dyld_error_str()
NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
if (dylderrstr && strlen(dylderrstr))
{
- retStr = malloc(strlen(dylderrstr) +1);
+ retStr = ast_malloc(strlen(dylderrstr) +1);
strcpy((char*)retStr,dylderrstr);
}
return retStr;
@@ -651,8 +651,8 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
else
{
if (savedErrorStr)
- free((char*)savedErrorStr);
- savedErrorStr = malloc(256);
+ ast_free(savedErrorStr);
+ savedErrorStr = ast_malloc(256);
snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol);
}
}
@@ -663,8 +663,8 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
if (!savedErrorStr || !strlen(savedErrorStr))
{
if (savedErrorStr)
- free((char*)savedErrorStr);
- savedErrorStr = malloc(256);
+ ast_free(savedErrorStr);
+ savedErrorStr = ast_malloc(256);
snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol);
}
if (canSetError)
@@ -676,7 +676,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
debug(savedErrorStr);
}
if (savedErrorStr)
- free((char*)savedErrorStr);
+ ast_free(savedErrorStr);
return NULL;
}
return NSAddressOfSymbol(nssym);
@@ -760,7 +760,7 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
error(errstr);
if ((dls->flags & DL_IN_LIST) == 0)
{
- free(dls);
+ ast_free(dls);
}
return NULL;
}
@@ -782,7 +782,7 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
NSLinkEditError(&ler, &lerno, &file, &errstr);
if ((dls->flags & DL_IN_LIST) == 0)
{
- free(dls);
+ ast_free(dls);
}
error(errstr);
return NULL;
@@ -828,10 +828,10 @@ static void dlcompat_cleanup(void)
char *data;
data = (char *)searchList();
if ( data )
- free( data );
+ ast_free(data);
data = (char *)getSearchPath(-1);
if ( data )
- free( data );
+ ast_free(data);
pthread_mutex_destroy(&dlcompat_mutex);
pthread_key_delete(dlerror_key);
next = stqueue;
@@ -839,7 +839,7 @@ static void dlcompat_cleanup(void)
{
dls = next;
next = dls->next;
- free(dls);
+ ast_free(dls);
}
}
@@ -852,7 +852,7 @@ static void resetdlerror()
static void dlerrorfree(void *data)
{
- free(data);
+ ast_free(data);
}
/* We kind of want a recursive lock here, but meet a little trouble
@@ -866,7 +866,7 @@ static inline void dolock(void)
tss = pthread_getspecific(dlerror_key);
if (!tss)
{
- tss = malloc(sizeof(struct dlthread));
+ tss = ast_malloc(sizeof(*tss));
tss->lockcnt = 0;
tss->errset = 0;
if (pthread_setspecific(dlerror_key, tss))
@@ -948,12 +948,12 @@ void *dlsym(void * dl_restrict handle, const char * dl_restrict symbol)
void *value = NULL;
char *malloc_sym = NULL;
dolock();
- malloc_sym = malloc(sym_len + 2);
+ malloc_sym = ast_malloc(sym_len + 2);
if (malloc_sym)
{
sprintf(malloc_sym, "_%s", symbol);
value = dlsymIntern(handle, malloc_sym, 1);
- free(malloc_sym);
+ ast_free(malloc_sym);
}
else
{
@@ -993,12 +993,12 @@ static void *dlsym_prepend_underscore_intern(void *handle, const char *symbol)
int sym_len = strlen(symbol);
void *value = NULL;
char *malloc_sym = NULL;
- malloc_sym = malloc(sym_len + 2);
+ malloc_sym = ast_malloc(sym_len + 2);
if (malloc_sym)
{
sprintf(malloc_sym, "_%s", symbol);
value = dlsymIntern(handle, malloc_sym, 1);
- free(malloc_sym);
+ ast_free(malloc_sym);
}
else
{
@@ -1293,12 +1293,12 @@ dlfunc_t dlfunc(void * dl_restrict handle, const char * dl_restrict symbol)
int sym_len = strlen(symbol);
char *malloc_sym = NULL;
dolock();
- malloc_sym = malloc(sym_len + 2);
+ malloc_sym = ast_malloc(sym_len + 2);
if (malloc_sym)
{
sprintf(malloc_sym, "_%s", symbol);
rv.d = dlsymIntern(handle, malloc_sym, 1);
- free(malloc_sym);
+ ast_free(malloc_sym);
}
else
{
diff --git a/main/dnsmgr.c b/main/dnsmgr.c
index 59c3a9994..1c5eb050b 100644
--- a/main/dnsmgr.c
+++ b/main/dnsmgr.c
@@ -116,7 +116,7 @@ void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
ast_verbose(VERBOSE_PREFIX_4 "removing dns manager for '%s'\n", entry->name);
ast_mutex_destroy(&entry->lock);
- free(entry);
+ ast_free(entry);
}
int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr)
diff --git a/main/dsp.c b/main/dsp.c
index 3d0712bc1..9519c56cc 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -1625,7 +1625,7 @@ void ast_dsp_set_features(struct ast_dsp *dsp, int features)
void ast_dsp_free(struct ast_dsp *dsp)
{
- free(dsp);
+ ast_free(dsp);
}
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
diff --git a/main/enum.c b/main/enum.c
index 140a38ff9..a860dcb4c 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -443,7 +443,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
}
if (chan && ast_autoservice_start(chan) < 0) {
- free(context);
+ ast_free(context);
return -1;
}
@@ -523,11 +523,11 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
if (!argcontext) {
for (k = 0; k < context->naptr_rrs_count; k++) {
- free(context->naptr_rrs[k].result);
- free(context->naptr_rrs[k].tech);
+ ast_free(context->naptr_rrs[k].result);
+ ast_free(context->naptr_rrs[k].tech);
}
- free(context->naptr_rrs);
- free(context);
+ ast_free(context->naptr_rrs);
+ ast_free(context);
} else
*argcontext = context;
@@ -622,7 +622,7 @@ int ast_enum_init(void)
while (s) {
sl = s;
s = s->next;
- free(sl);
+ ast_free(sl);
}
toplevs = NULL;
cfg = ast_config_load("enum.conf");
diff --git a/main/event.c b/main/event.c
index ffa2912b0..905790614 100644
--- a/main/event.c
+++ b/main/event.c
@@ -109,9 +109,9 @@ static AST_RWLIST_HEAD(ast_event_ref_list, ast_event_ref) ast_event_cache[AST_EV
static void ast_event_ie_val_destroy(struct ast_event_ie_val *ie_val)
{
if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
- free((void *) ie_val->payload.str);
+ ast_free((void *) ie_val->payload.str);
- free(ie_val);
+ ast_free(ie_val);
}
enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type type, ...)
@@ -270,7 +270,7 @@ struct ast_event_sub *ast_event_subscribe(enum ast_event_type type, ast_event_cb
ie_val->payload.uint = va_arg(ap, uint32_t);
else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR) {
if (!(ie_val->payload.str = ast_strdup(va_arg(ap, const char *)))) {
- free(ie_val);
+ ast_free(ie_val);
continue;
}
}
@@ -327,7 +327,7 @@ static void ast_event_sub_destroy(struct ast_event_sub *sub)
while ((ie_val = AST_LIST_REMOVE_HEAD(&sub->ie_vals, entry)))
ast_event_ie_val_destroy(ie_val);
- free(sub);
+ ast_free(sub);
}
void ast_event_unsubscribe(struct ast_event_sub *sub)
@@ -481,13 +481,13 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
void ast_event_destroy(struct ast_event *event)
{
- free(event);
+ ast_free(event);
}
static void ast_event_ref_destroy(struct ast_event_ref *event_ref)
{
ast_event_destroy(event_ref->event);
- free(event_ref);
+ ast_free(event_ref);
}
static struct ast_event *ast_event_dup(const struct ast_event *event)
diff --git a/main/file.c b/main/file.c
index 038dd5f3a..a7c5bfe93 100644
--- a/main/file.c
+++ b/main/file.c
@@ -112,7 +112,7 @@ int ast_format_unregister(const char *name)
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) {
if (!strcasecmp(name, tmp->name)) {
AST_RWLIST_REMOVE_CURRENT(&formats, list);
- free(tmp);
+ ast_free(tmp);
res = 0;
}
}
@@ -372,7 +372,7 @@ static int ast_filehelper(const char *filename, const void *arg2, const char *fm
continue;
if ( stat(fn, &st) ) { /* file not existent */
- free(fn);
+ ast_free(fn);
continue;
}
/* for 'OPEN' we need to be sure that the format matches
@@ -385,23 +385,23 @@ static int ast_filehelper(const char *filename, const void *arg2, const char *fm
if ( !(chan->writeformat & f->format) &&
!(f->format >= AST_FORMAT_MAX_AUDIO && fmt)) {
- free(fn);
+ ast_free(fn);
continue; /* not a supported format */
}
if ( (bfile = fopen(fn, "r")) == NULL) {
- free(fn);
+ ast_free(fn);
continue; /* cannot open file */
}
s = get_filestream(f, bfile);
if (!s) {
fclose(bfile);
- free(fn); /* cannot allocate descriptor */
+ ast_free(fn); /* cannot allocate descriptor */
continue;
}
if (open_wrapper(s)) {
fclose(bfile);
- free(fn);
- free(s);
+ ast_free(fn);
+ ast_free(s);
continue; /* cannot run open on file */
}
/* ok this is good for OPEN */
@@ -419,7 +419,7 @@ static int ast_filehelper(const char *filename, const void *arg2, const char *fm
ast_closestream(chan->vstream);
chan->vstream = s;
}
- free(fn);
+ ast_free(fn);
break;
}
switch (action) {
@@ -446,7 +446,7 @@ static int ast_filehelper(const char *filename, const void *arg2, const char *fm
ast_log(LOG_WARNING, "%s(%s,%s) failed: %s\n",
action == ACTION_COPY ? "copy" : "rename",
fn, nfn, strerror(errno));
- free(nfn);
+ ast_free(nfn);
}
}
break;
@@ -454,7 +454,7 @@ static int ast_filehelper(const char *filename, const void *arg2, const char *fm
default:
ast_log(LOG_WARNING, "Unknown helper %d\n", action);
}
- free(fn);
+ ast_free(fn);
}
}
AST_RWLIST_UNLOCK(&formats);
@@ -732,16 +732,16 @@ int ast_closestream(struct ast_filestream *f)
}
if (f->filename)
- free(f->filename);
+ ast_free(f->filename);
if (f->realfilename)
- free(f->realfilename);
+ ast_free(f->realfilename);
if (f->fmt->close)
f->fmt->close(f);
fclose(f->f);
if (f->vfs)
ast_closestream(f->vfs);
ast_module_unref(f->fmt->module);
- free(f);
+ ast_free(f);
return 0;
}
@@ -833,7 +833,7 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons
ast_free(fs);
if (bfile)
fclose(bfile);
- free(fn);
+ ast_free(fn);
continue;
}
/* found it */
@@ -919,7 +919,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
strcpy(buf, record_cache_dir);
strcat(buf, "/");
strcat(buf, fn);
- free(fn);
+ ast_free(fn);
fn = buf;
fd = open(fn, flags | myflags, mode);
if (fd > -1) {
@@ -966,7 +966,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
}
/* if buf != NULL then fn is already free and pointing to it */
if (!buf)
- free(fn);
+ ast_free(fn);
}
AST_RWLIST_UNLOCK(&formats);
diff --git a/main/fixedjitterbuf.c b/main/fixedjitterbuf.c
index 1d7a5cc30..a9d0f8707 100644
--- a/main/fixedjitterbuf.c
+++ b/main/fixedjitterbuf.c
@@ -66,12 +66,12 @@ static int resynch_jb(struct fixed_jb *jb, void *data, long ms, long ts, long no
static inline struct fixed_jb_frame *alloc_jb_frame(struct fixed_jb *jb)
{
- return ast_calloc(1, sizeof(struct fixed_jb_frame));
+ return ast_calloc(1, sizeof(*jb));
}
static inline void release_jb_frame(struct fixed_jb *jb, struct fixed_jb_frame *frame)
{
- free(frame);
+ ast_free(frame);
}
static void get_jb_head(struct fixed_jb *jb, struct fixed_jb_frame *frame)
@@ -131,7 +131,7 @@ void fixed_jb_destroy(struct fixed_jb *jb)
/* jitterbuf MUST be empty before it can be destroyed */
ASSERT(jb->frames == NULL);
- free(jb);
+ ast_free(jb);
}
diff --git a/main/frame.c b/main/frame.c
index 068d46e46..8f30e4b7e 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -285,7 +285,7 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s)
void ast_smoother_free(struct ast_smoother *s)
{
- free(s);
+ ast_free(s);
}
static struct ast_frame *ast_frame_header_new(void)
@@ -330,9 +330,9 @@ static void frame_cache_cleanup(void *data)
struct ast_frame *f;
while ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list)))
- free(f);
+ ast_free(f);
- free(frames);
+ ast_free(frames);
}
#endif
@@ -358,11 +358,11 @@ void ast_frame_free(struct ast_frame *fr, int cache)
if (fr->mallocd & AST_MALLOCD_DATA) {
if (fr->data)
- free(fr->data - fr->offset);
+ ast_free(fr->data - fr->offset);
}
if (fr->mallocd & AST_MALLOCD_SRC) {
if (fr->src)
- free((char *)fr->src);
+ ast_free((char *)fr->src);
}
if (fr->mallocd & AST_MALLOCD_HDR) {
#ifdef TRACE_FRAMES
@@ -371,7 +371,7 @@ void ast_frame_free(struct ast_frame *fr, int cache)
AST_LIST_REMOVE(&headerlist, fr, frame_list);
AST_LIST_UNLOCK(&headerlist);
#endif
- free(fr);
+ ast_free(fr);
}
}
@@ -409,7 +409,7 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr)
if (fr->src) {
if (!(out->src = ast_strdup(fr->src))) {
if (out != fr)
- free(out);
+ ast_free(out);
return NULL;
}
}
@@ -419,9 +419,9 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr)
if (!(fr->mallocd & AST_MALLOCD_DATA)) {
if (!(newdata = ast_malloc(fr->datalen + AST_FRIENDLY_OFFSET))) {
if (out->src != fr->src)
- free((void *) out->src);
+ ast_free((void *) out->src);
if (out != fr)
- free(out);
+ ast_free(out);
return NULL;
}
newdata += AST_FRIENDLY_OFFSET;
diff --git a/main/http.c b/main/http.c
index 5d652b8dc..2967298e7 100644
--- a/main/http.c
+++ b/main/http.c
@@ -206,7 +206,7 @@ static struct ast_str *static_callback(struct sockaddr_in *req, const char *uri,
*contentlength = read(fd, result->str + result->used, st.st_size);
if (*contentlength < 0) {
close(fd);
- free(result);
+ ast_free(result);
goto out403;
}
result->used += *contentlength;
@@ -747,7 +747,7 @@ static void *make_file_from_fd(void *data)
if (!ser->f) {
close(ser->fd);
ast_log(LOG_WARNING, "FILE * open failed!\n");
- free(ser);
+ ast_free(ser);
return NULL;
}
return ser->parent->worker_fn(ser);
@@ -888,14 +888,14 @@ static void *httpd_helper_thread(void *data)
fwrite(tmp + 4, 1, contentlength, ser->f);
}
}
- free(out);
+ ast_free(out);
}
if (title)
- free(title);
+ ast_free(title);
done:
fclose(ser->f);
- free(ser);
+ ast_free(ser);
return NULL;
}
@@ -938,7 +938,7 @@ void *server_root(void *data)
if (ast_pthread_create_detached_background(&launched, NULL, make_file_from_fd, ser)) {
ast_log(LOG_WARNING, "Unable to launch helper thread: %s\n", strerror(errno));
close(ser->fd);
- free(ser);
+ ast_free(ser);
}
}
@@ -1107,10 +1107,10 @@ static void add_redirect(const char *value)
static void destroy_post_mapping(struct ast_http_post_mapping *post_map)
{
if (post_map->from)
- free(post_map->from);
+ ast_free(post_map->from);
if (post_map->to)
- free(post_map->to);
- free(post_map);
+ ast_free(post_map->to);
+ ast_free(post_map);
}
static void destroy_post_mappings(void)
@@ -1168,15 +1168,15 @@ static int __ast_http_load(int reload)
http_tls_cfg.enabled = 0;
if (http_tls_cfg.certfile)
- free(http_tls_cfg.certfile);
+ ast_free(http_tls_cfg.certfile);
http_tls_cfg.certfile = ast_strdup(AST_CERTFILE);
if (http_tls_cfg.cipher)
- free(http_tls_cfg.cipher);
+ ast_free(http_tls_cfg.cipher);
http_tls_cfg.cipher = ast_strdup("");
AST_RWLIST_WRLOCK(&uri_redirects);
while ((redirect = AST_RWLIST_REMOVE_HEAD(&uri_redirects, entry)))
- free(redirect);
+ ast_free(redirect);
AST_RWLIST_UNLOCK(&uri_redirects);
destroy_post_mappings();
@@ -1192,10 +1192,10 @@ static int __ast_http_load(int reload)
else if (!strcasecmp(v->name, "sslbindport"))
https_desc.sin.sin_port = htons(atoi(v->value));
else if (!strcasecmp(v->name, "sslcert")) {
- free(http_tls_cfg.certfile);
+ ast_free(http_tls_cfg.certfile);
http_tls_cfg.certfile = ast_strdup(v->value);
} else if (!strcasecmp(v->name, "sslcipher")) {
- free(http_tls_cfg.cipher);
+ ast_free(http_tls_cfg.cipher);
http_tls_cfg.cipher = ast_strdup(v->value);
}
else if (!strcasecmp(v->name, "enablestatic"))
diff --git a/main/indications.c b/main/indications.c
index c58a51660..cc714707f 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -108,9 +108,9 @@ static void playtones_release(struct ast_channel *chan, void *params)
if (chan)
ast_set_write_format(chan, ps->origwfmt);
if (ps->items)
- free(ps->items);
+ ast_free(ps->items);
- free(ps);
+ ast_free(ps);
}
static void * playtones_alloc(struct ast_channel *chan, void *params)
@@ -324,7 +324,7 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst,
}
if (ast_activate_generator(chan, &playtones, &d)) {
- free(d.items);
+ ast_free(d.items);
return -1;
}
return 0;
@@ -453,16 +453,16 @@ static inline void free_zone(struct ind_tone_zone* zone)
{
while (zone->tones) {
struct ind_tone_zone_sound *tmp = zone->tones->next;
- free((void*)zone->tones->name);
- free((void*)zone->tones->data);
- free(zone->tones);
+ ast_free((void *)zone->tones->name);
+ ast_free((void *)zone->tones->data);
+ ast_free(zone->tones);
zone->tones = tmp;
}
if (zone->ringcadence)
- free(zone->ringcadence);
+ ast_free(zone->ringcadence);
- free(zone);
+ ast_free(zone);
}
/*--------------------------------------------*/
@@ -543,8 +543,8 @@ int ast_register_indication(struct ind_tone_zone *zone, const char *indication,
for (ps=NULL,ts=zone->tones; ts; ps=ts,ts=ts->next) {
if (strcasecmp(indication,ts->name)==0) {
/* indication already there, replace */
- free((void*)ts->name);
- free((void*)ts->data);
+ ast_free((void*)ts->name);
+ ast_free((void*)ts->data);
break;
}
}
@@ -588,9 +588,9 @@ int ast_unregister_indication(struct ind_tone_zone *zone, const char *indication
ps->next = tmp;
else
zone->tones = tmp;
- free((void*)ts->name);
- free((void*)ts->data);
- free(ts);
+ ast_free((void*)ts->name);
+ ast_free((void*)ts->data);
+ ast_free(ts);
ts = tmp;
res = 0;
}
diff --git a/main/io.c b/main/io.c
index 209f27926..a2ab16635 100644
--- a/main/io.c
+++ b/main/io.c
@@ -87,12 +87,12 @@ struct io_context *io_context_create(void)
tmp->current_ioc = -1;
if (!(tmp->fds = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->fds)))) {
- free(tmp);
+ ast_free(tmp);
tmp = NULL;
} else {
if (!(tmp->ior = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->ior)))) {
- free(tmp->fds);
- free(tmp);
+ ast_free(tmp->fds);
+ ast_free(tmp);
tmp = NULL;
}
}
@@ -104,11 +104,11 @@ void io_context_destroy(struct io_context *ioc)
{
/* Free associated memory with an I/O context */
if (ioc->fds)
- free(ioc->fds);
+ ast_free(ioc->fds);
if (ioc->ior)
- free(ioc->ior);
+ ast_free(ioc->ior);
- free(ioc);
+ ast_free(ioc);
}
/*! \brief
@@ -250,7 +250,7 @@ int ast_io_remove(struct io_context *ioc, int *_id)
for (x = 0; x < ioc->fdcnt; x++) {
if (ioc->ior[x].id == _id) {
/* Free the int immediately and set to NULL so we know it's unused now */
- free(ioc->ior[x].id);
+ ast_free(ioc->ior[x].id);
ioc->ior[x].id = NULL;
ioc->fds[x].events = 0;
ioc->fds[x].revents = 0;
diff --git a/main/jitterbuf.c b/main/jitterbuf.c
index f41e0d382..177e2e625 100644
--- a/main/jitterbuf.c
+++ b/main/jitterbuf.c
@@ -106,12 +106,12 @@ void jb_destroy(jitterbuf *jb)
frame = jb->free;
while (frame != NULL) {
jb_frame *next = frame->next;
- free(frame);
+ ast_free(frame);
frame = next;
}
/* free ourselves! */
- free(jb);
+ ast_free(jb);
}
diff --git a/main/loader.c b/main/loader.c
index c1b7597c9..060243ccc 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -170,7 +170,7 @@ void ast_module_unregister(const struct ast_module_info *info)
if (mod) {
AST_LIST_HEAD_DESTROY(&mod->users);
- free(mod);
+ ast_free(mod);
}
}
@@ -201,7 +201,7 @@ void __ast_module_user_remove(struct ast_module *mod, struct ast_module_user *u)
AST_LIST_REMOVE(&mod->users, u, entry);
AST_LIST_UNLOCK(&mod->users);
ast_atomic_fetchadd_int(&mod->usecount, -1);
- free(u);
+ ast_free(u);
ast_update_use_count();
}
@@ -214,7 +214,7 @@ void __ast_module_user_hangup_all(struct ast_module *mod)
while ((u = AST_LIST_REMOVE_HEAD(&mod->users, entry))) {
ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD);
ast_atomic_fetchadd_int(&mod->usecount, -1);
- free(u);
+ ast_free(u);
}
AST_LIST_UNLOCK(&mod->users);
@@ -359,7 +359,7 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned
if (!(lib = dlopen(fn, RTLD_LAZY | RTLD_LOCAL))) {
ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror());
- free(resource_being_loaded);
+ ast_free(resource_being_loaded);
return NULL;
}
@@ -396,7 +396,7 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned
if (!dlopen(fn, RTLD_NOLOAD | (wants_global ? RTLD_LAZY | RTLD_GLOBAL : RTLD_NOW | RTLD_LOCAL))) {
ast_log(LOG_WARNING, "Unable to promote flags on module '%s': %s\n", resource_in, dlerror());
while (!dlclose(lib));
- free(resource_being_loaded);
+ ast_free(resource_being_loaded);
return NULL;
}
#else
@@ -412,7 +412,7 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned
if (!(lib = dlopen(fn, wants_global ? RTLD_LAZY | RTLD_GLOBAL : RTLD_NOW | RTLD_LOCAL))) {
ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror());
- free(resource_being_loaded);
+ ast_free(resource_being_loaded);
return NULL;
}
@@ -816,8 +816,8 @@ int load_modules(unsigned int preload_only)
AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) {
if (!resource_name_match(order->resource, v->value)) {
AST_LIST_REMOVE_CURRENT(&load_order, entry);
- free(order->resource);
- free(order);
+ ast_free(order->resource);
+ ast_free(order);
}
}
AST_LIST_TRAVERSE_SAFE_END;
@@ -840,8 +840,8 @@ int load_modules(unsigned int preload_only)
case AST_MODULE_LOAD_SUCCESS:
case AST_MODULE_LOAD_DECLINE:
AST_LIST_REMOVE_CURRENT(&load_order, entry);
- free(order->resource);
- free(order);
+ ast_free(order->resource);
+ ast_free(order);
break;
case AST_MODULE_LOAD_FAILURE:
res = -1;
@@ -859,8 +859,8 @@ int load_modules(unsigned int preload_only)
case AST_MODULE_LOAD_SUCCESS:
case AST_MODULE_LOAD_DECLINE:
AST_LIST_REMOVE_CURRENT(&load_order, entry);
- free(order->resource);
- free(order);
+ ast_free(order->resource);
+ ast_free(order);
break;
case AST_MODULE_LOAD_FAILURE:
res = -1;
@@ -874,8 +874,8 @@ int load_modules(unsigned int preload_only)
done:
while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) {
- free(order->resource);
- free(order);
+ ast_free(order->resource);
+ ast_free(order);
}
AST_LIST_UNLOCK(&module_list);
diff --git a/main/manager.c b/main/manager.c
index 102ce69dc..6bffad2f6 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -295,7 +295,7 @@ static void purge_events(void)
while ( (ev = AST_LIST_FIRST(&all_events)) &&
ev->usecount == 0 && AST_LIST_NEXT(ev, eq_next)) {
AST_LIST_REMOVE_HEAD(&all_events, eq_next);
- free(ev);
+ ast_free(ev);
}
AST_LIST_UNLOCK(&all_events);
}
@@ -696,7 +696,7 @@ static void free_session(struct mansession *s)
if (s->f != NULL)
fclose(s->f);
ast_mutex_destroy(&s->__lock);
- free(s);
+ ast_free(s);
unref_event(eqe);
}
@@ -1889,7 +1889,7 @@ static void *fast_originate(void *data)
/* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
if (chan)
ast_channel_unlock(chan);
- free(in);
+ ast_free(in);
return NULL;
}
@@ -2501,7 +2501,7 @@ static void *session_do(void *data)
destroy_session(s);
done:
- free(ser);
+ ast_free(ser);
return NULL;
}
@@ -2641,7 +2641,7 @@ int ast_manager_unregister(char *action)
prev->next = cur->next;
else
first_action = cur->next;
- free(cur);
+ ast_free(cur);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Manager unregistered action %s\n", action);
break;
@@ -3273,10 +3273,10 @@ int init_manager(void)
ami_tls_cfg.enabled = 0;
if (ami_tls_cfg.certfile)
- free(ami_tls_cfg.certfile);
+ ast_free(ami_tls_cfg.certfile);
ami_tls_cfg.certfile = ast_strdup(AST_CERTFILE);
if (ami_tls_cfg.cipher)
- free(ami_tls_cfg.cipher);
+ ast_free(ami_tls_cfg.cipher);
ami_tls_cfg.cipher = ast_strdup("");
for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
@@ -3293,10 +3293,10 @@ int init_manager(void)
ast_log(LOG_WARNING, "Invalid bind address '%s'\n", val);
}
} else if (!strcasecmp(var->name, "sslcert")) {
- free(ami_tls_cfg.certfile);
+ ast_free(ami_tls_cfg.certfile);
ami_tls_cfg.certfile = ast_strdup(val);
} else if (!strcasecmp(var->name, "sslcipher")) {
- free(ami_tls_cfg.cipher);
+ ast_free(ami_tls_cfg.cipher);
ami_tls_cfg.cipher = ast_strdup(val);
} else if (!strcasecmp(var->name, "enabled")) {
manager_enabled = ast_true(val);
@@ -3359,23 +3359,23 @@ int init_manager(void)
while (var) {
if (!strcasecmp(var->name, "secret")) {
if (user->secret)
- free(user->secret);
+ ast_free(user->secret);
user->secret = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "deny") ) {
if (user->deny)
- free(user->deny);
+ ast_free(user->deny);
user->deny = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "permit") ) {
if (user->permit)
- free(user->permit);
+ ast_free(user->permit);
user->permit = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "read") ) {
if (user->read)
- free(user->read);
+ ast_free(user->read);
user->read = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "write") ) {
if (user->write)
- free(user->write);
+ ast_free(user->write);
user->write = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "displayconnects") )
user->displayconnects = ast_true(var->value);
@@ -3397,16 +3397,16 @@ int init_manager(void)
AST_LIST_REMOVE_CURRENT(&users, list);
/* Free their memory now */
if (user->secret)
- free(user->secret);
+ ast_free(user->secret);
if (user->deny)
- free(user->deny);
+ ast_free(user->deny);
if (user->permit)
- free(user->permit);
+ ast_free(user->permit);
if (user->read)
- free(user->read);
+ ast_free(user->read);
if (user->write)
- free(user->write);
- free(user);
+ ast_free(user->write);
+ ast_free(user);
}
AST_LIST_TRAVERSE_SAFE_END
diff --git a/main/netsock.c b/main/netsock.c
index 2ce60b8c4..e57c376ee 100644
--- a/main/netsock.c
+++ b/main/netsock.c
@@ -80,7 +80,7 @@ static void ast_netsock_destroy(struct ast_netsock *netsock)
{
ast_io_remove(netsock->ioc, netsock->ioref);
close(netsock->sockfd);
- free(netsock);
+ ast_free(netsock);
}
struct ast_netsock_list *ast_netsock_list_alloc(void)
@@ -147,7 +147,7 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
ast_enable_packet_fragmentation(netsocket);
- if (!(ns = ast_calloc(1, sizeof(struct ast_netsock)))) {
+ if (!(ns = ast_calloc(1, sizeof(*ns)))) {
close(netsocket);
return NULL;
}
@@ -155,7 +155,7 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
/* Establish I/O callback for socket read */
if (!(ioref = ast_io_add(ioc, netsocket, callback, AST_IO_IN, ns))) {
close(netsocket);
- free(ns);
+ ast_free(ns);
return NULL;
}
ASTOBJ_INIT(ns);
diff --git a/main/pbx.c b/main/pbx.c
index ac32bffe7..90dd7ed74 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -609,7 +609,7 @@ static inline int include_valid(struct ast_include *i)
static void pbx_destroy(struct ast_pbx *p)
{
- free(p);
+ ast_free(p);
}
/*
@@ -2022,7 +2022,7 @@ static void *device_state_thread(void *data)
handle_statechange(sc->dev);
- free(sc);
+ ast_free(sc);
}
return NULL;
@@ -2133,7 +2133,7 @@ int ast_extension_state_del(int id, ast_state_cb_type callback)
if (p_cur && *p_cur) {
struct ast_state_cb *cur = *p_cur;
*p_cur = cur->next;
- free(cur);
+ ast_free(cur);
ret = 0;
}
AST_RWLIST_UNLOCK(&hints);
@@ -2215,11 +2215,11 @@ static int ast_remove_hint(struct ast_exten *e)
cbprev = cblist;
cblist = cblist->next;
cbprev->callback(hint->exten->parent->name, hint->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data);
- free(cbprev);
+ ast_free(cbprev);
}
hint->callbacks = NULL;
AST_RWLIST_REMOVE_CURRENT(&hints, list);
- free(hint);
+ ast_free(hint);
res = 0;
break;
}
@@ -2326,7 +2326,7 @@ static int __ast_pbx_run(struct ast_channel *c)
if (c->pbx) {
ast_log(LOG_WARNING, "%s already has PBX structure??\n", c->name);
/* XXX and now what ? */
- free(c->pbx);
+ ast_free(c->pbx);
}
if (!(c->pbx = ast_calloc(1, sizeof(*c->pbx))))
return -1;
@@ -2335,7 +2335,7 @@ static int __ast_pbx_run(struct ast_channel *c)
c->cdr = ast_cdr_alloc();
if (!c->cdr) {
ast_log(LOG_WARNING, "Unable to create Call Detail Record\n");
- free(c->pbx);
+ ast_free(c->pbx);
return -1;
}
ast_cdr_init(c->cdr, c);
@@ -2593,7 +2593,7 @@ static void destroy_exten(struct ast_exten *e)
if (e->datad)
e->datad(e->data);
- free(e);
+ ast_free(e);
}
static void *pbx_thread(void *data)
@@ -2722,7 +2722,7 @@ int ast_context_remove_include2(struct ast_context *con, const char *include, co
else
con->includes = i->next;
/* free include and return */
- free(i);
+ ast_free(i);
ret = 0;
break;
}
@@ -2772,7 +2772,7 @@ int ast_context_remove_switch2(struct ast_context *con, const char *sw, const ch
(!registrar || !strcmp(i->registrar, registrar))) {
/* found, remove from list */
AST_LIST_REMOVE_CURRENT(&con->alts, list);
- free(i); /* free switch and return */
+ ast_free(i); /* free switch and return */
ret = 0;
break;
}
@@ -3925,7 +3925,7 @@ int ast_unregister_application(const char *app)
AST_RWLIST_REMOVE_CURRENT(&apps, list);
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name);
- free(tmp);
+ ast_free(tmp);
break;
}
}
@@ -4083,7 +4083,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char
prevcb = thiscb;
thiscb = thiscb->next;
prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data);
- free(prevcb);
+ ast_free(prevcb);
}
} else {
thiscb = this->callbacks;
@@ -4093,7 +4093,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char
hint->callbacks = this->callbacks;
hint->laststate = this->laststate;
}
- free(this);
+ ast_free(this);
}
AST_RWLIST_UNLOCK(&hints);
@@ -4406,7 +4406,7 @@ int ast_context_add_include2(struct ast_context *con, const char *value,
/* ... go to last include and check if context is already included too... */
for (i = con->includes; i; i = i->next) {
if (!strcasecmp(i->name, new_include->name)) {
- free(new_include);
+ ast_free(new_include);
ast_unlock_context(con);
errno = EEXIST;
return -1;
@@ -4497,7 +4497,7 @@ int ast_context_add_switch2(struct ast_context *con, const char *value,
/* ... go to last sw and check if context is already swd too... */
AST_LIST_TRAVERSE(&con->alts, i, list) {
if (!strcasecmp(i->name, new_sw->name) && !strcasecmp(i->data, new_sw->data)) {
- free(new_sw);
+ ast_free(new_sw);
ast_unlock_context(con);
errno = EEXIST;
return -1;
@@ -4542,10 +4542,10 @@ int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat
(!registrar || (registrar == ip->registrar))) {
if (ipl) {
ipl->next = ip->next;
- free(ip);
+ ast_free(ip);
} else {
con->ignorepats = ip->next;
- free(ip);
+ ast_free(ip);
}
ast_unlock_context(con);
return 0;
@@ -4766,7 +4766,7 @@ static int add_pri(struct ast_context *con, struct ast_exten *tmp,
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);
- free(tmp);
+ ast_free(tmp);
return -1;
}
/* we are replacing e, so copy the link fields and then update
@@ -4785,7 +4785,7 @@ static int add_pri(struct ast_context *con, struct ast_exten *tmp,
/* Destroy the old one */
if (e->datad)
e->datad(e->data);
- free(e);
+ ast_free(e);
} else { /* Slip ourselves in just before e */
tmp->peer = e;
tmp->next = e->next; /* extension chain, or NULL if e is not the first extension */
@@ -5020,7 +5020,7 @@ static void *async_wait(void *data)
}
}
}
- free(as);
+ ast_free(as);
if (chan)
ast_hangup(chan);
return NULL;
@@ -5162,7 +5162,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
ast_channel_lock(chan);
}
if (!chan) {
- free(as);
+ ast_free(as);
res = -1;
goto outgoing_exten_cleanup;
}
@@ -5175,7 +5175,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
ast_cdr_setaccount(chan, account);
if (ast_pthread_create_detached(&as->p, NULL, async_wait, as)) {
ast_log(LOG_WARNING, "Failed to start async wait\n");
- free(as);
+ ast_free(as);
if (channel) {
*channel = NULL;
ast_channel_unlock(chan);
@@ -5211,7 +5211,7 @@ static void *ast_pbx_run_app(void *data)
} else
ast_log(LOG_WARNING, "No such application '%s'\n", tmp->app);
ast_hangup(tmp->chan);
- free(tmp);
+ ast_free(tmp);
return NULL;
}
@@ -5241,7 +5241,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
chan->cdr = ast_cdr_alloc(); /* allocate a cdr for the channel */
if (!chan->cdr) {
/* allocation of the cdr failed */
- free(chan->pbx);
+ ast_free(chan->pbx);
res = -1;
goto outgoing_app_cleanup;
}
@@ -5273,7 +5273,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
ast_channel_lock(chan);
if (ast_pthread_create_detached(&tmp->t, NULL, ast_pbx_run_app, tmp)) {
ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
- free(tmp);
+ ast_free(tmp);
if (locked_channel)
ast_channel_unlock(chan);
ast_hangup(chan);
@@ -5316,7 +5316,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
}
chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh);
if (!chan) {
- free(as);
+ ast_free(as);
res = -1;
goto outgoing_app_cleanup;
}
@@ -5333,7 +5333,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
ast_channel_lock(chan);
if (ast_pthread_create_detached(&as->p, NULL, async_wait, as)) {
ast_log(LOG_WARNING, "Failed to start async wait\n");
- free(as);
+ ast_free(as);
if (locked_channel)
ast_channel_unlock(chan);
ast_hangup(chan);
@@ -5383,15 +5383,15 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar)
for (tmpi = tmp->includes; tmpi; ) { /* Free includes */
struct ast_include *tmpil = tmpi;
tmpi = tmpi->next;
- free(tmpil);
+ ast_free(tmpil);
}
for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */
struct ast_ignorepat *ipl = ipi;
ipi = ipi->next;
- free(ipl);
+ ast_free(ipl);
}
while ((sw = AST_LIST_REMOVE_HEAD(&tmp->alts, list)))
- free(sw);
+ ast_free(sw);
for (e = tmp->root; e;) {
for (en = e->peer; en;) {
el = en;
@@ -5403,7 +5403,7 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar)
destroy_exten(el);
}
ast_rwlock_destroy(&tmp->lock);
- free(tmp);
+ ast_free(tmp);
/* if we have a specific match, we are done, otherwise continue */
tmp = con ? NULL : next;
}
diff --git a/main/rtp.c b/main/rtp.c
index 1ae1edc1b..617136b55 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -1936,7 +1936,7 @@ static struct ast_rtcp *ast_rtcp_new(void)
rtcp->them.sin_family = AF_INET;
if (rtcp->s < 0) {
- free(rtcp);
+ ast_free(rtcp);
ast_log(LOG_WARNING, "Unable to allocate RTCP socket: %s\n", strerror(errno));
return NULL;
}
@@ -1977,7 +1977,7 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io
rtp->s = rtp_socket();
if (rtp->s < 0) {
- free(rtp);
+ ast_free(rtp);
ast_log(LOG_ERROR, "Unable to allocate socket: %s\n", strerror(errno));
return NULL;
}
@@ -2017,9 +2017,9 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io
close(rtp->s);
if (rtp->rtcp) {
close(rtp->rtcp->s);
- free(rtp->rtcp);
+ ast_free(rtp->rtcp);
}
- free(rtp);
+ ast_free(rtp);
return NULL;
}
/* The port was used, increment it (by two). */
@@ -2035,9 +2035,9 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io
close(rtp->s);
if (rtp->rtcp) {
close(rtp->rtcp->s);
- free(rtp->rtcp);
+ ast_free(rtp->rtcp);
}
- free(rtp);
+ ast_free(rtp);
return NULL;
}
}
@@ -2204,13 +2204,13 @@ void ast_rtp_destroy(struct ast_rtp *rtp)
if (rtp->rtcp->schedid > 0)
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
close(rtp->rtcp->s);
- free(rtp->rtcp);
+ ast_free(rtp->rtcp);
rtp->rtcp=NULL;
}
#ifdef P2P_INTENSE
ast_mutex_destroy(&rtp->bridge_lock);
#endif
- free(rtp);
+ ast_free(rtp);
}
static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval *delivery)
diff --git a/main/say.c b/main/say.c
index 582ffb2ec..92fec372e 100644
--- a/main/say.c
+++ b/main/say.c
@@ -1962,7 +1962,7 @@ and combinations of eg.: 20_1, 30m_3m, etc...
static odmiana *odmiana_zenska = NULL;
if (odmiana_nieosobowa == NULL) {
- odmiana_nieosobowa = (odmiana *) malloc(sizeof(odmiana));
+ odmiana_nieosobowa = ast_malloc(sizeof(*odmiana_nieosobowa));
odmiana_nieosobowa->separator_dziesiatek = " ";
@@ -1975,7 +1975,7 @@ and combinations of eg.: 20_1, 30m_3m, etc...
}
if (odmiana_zenska == NULL) {
- odmiana_zenska = (odmiana *) malloc(sizeof(odmiana));
+ odmiana_zenska = ast_malloc(sizeof(*odmiana_zenska));
odmiana_zenska->separator_dziesiatek = " ";
@@ -1988,7 +1988,7 @@ and combinations of eg.: 20_1, 30m_3m, etc...
}
if (odmiana_meska == NULL) {
- odmiana_meska = (odmiana *) malloc(sizeof(odmiana));
+ odmiana_meska = ast_malloc(sizeof(*odmiana_meska));
odmiana_meska->separator_dziesiatek = " ";
@@ -6908,7 +6908,7 @@ static int ast_say_number_full_ge(struct ast_channel *chan, int num, const char
while (res == 0 && (s = strstr(remainder, " "))) {
size_t len = s - remainder;
- char* new_string = malloc(len + 1 + strlen("digits/"));
+ char* new_string = ast_malloc(len + 1 + strlen("digits/"));
sprintf(new_string, "digits/");
strncat(new_string, remainder, len); /* we can't sprintf() it, it's not null-terminated. */
@@ -6922,7 +6922,7 @@ static int ast_say_number_full_ge(struct ast_channel *chan, int num, const char
}
ast_stopstream(chan);
- free(new_string);
+ ast_free(new_string);
remainder = s + 1; /* position just after the found space char. */
while(*remainder == ' ') /* skip multiple spaces */
@@ -6933,7 +6933,7 @@ static int ast_say_number_full_ge(struct ast_channel *chan, int num, const char
/* the last chunk. */
if (res == 0 && *remainder) {
- char* new_string = malloc(strlen(remainder) + 1 + strlen("digits/"));
+ char* new_string = ast_malloc(strlen(remainder) + 1 + strlen("digits/"));
sprintf(new_string, "digits/%s", remainder);
if (!ast_streamfile(chan, new_string, language)) {
@@ -6944,7 +6944,7 @@ static int ast_say_number_full_ge(struct ast_channel *chan, int num, const char
}
ast_stopstream(chan);
- free(new_string);
+ ast_free(new_string);
}
diff --git a/main/sched.c b/main/sched.c
index 851e07db5..9aac2cde7 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -94,17 +94,17 @@ void sched_context_destroy(struct sched_context *con)
#ifdef SCHED_MAX_CACHE
/* Eliminate the cache */
while ((s = AST_LIST_REMOVE_HEAD(&con->schedc, list)))
- free(s);
+ ast_free(s);
#endif
/* And the queue */
while ((s = AST_LIST_REMOVE_HEAD(&con->schedq, list)))
- free(s);
+ ast_free(s);
/* And the context */
ast_mutex_unlock(&con->lock);
ast_mutex_destroy(&con->lock);
- free(con);
+ ast_free(con);
}
static struct sched *sched_alloc(struct sched_context *con)
@@ -138,7 +138,7 @@ static void sched_release(struct sched_context *con, struct sched *tmp)
con->schedccnt++;
} else
#endif
- free(tmp);
+ ast_free(tmp);
}
/*! \brief
diff --git a/main/strcompat.c b/main/strcompat.c
index dbad22b75..912f64dea 100644
--- a/main/strcompat.c
+++ b/main/strcompat.c
@@ -141,7 +141,7 @@ size_t strnlen(const char *s, size_t n)
char *strndup(const char *s, size_t n)
{
size_t len = strnlen(s, n);
- char *new = malloc(len + 1);
+ char *new = ast_malloc(len + 1);
if (!new)
return NULL;
@@ -162,7 +162,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
va_copy(ap2, ap);
size = vsnprintf(&s, 1, fmt, ap2);
va_end(ap2);
- *strp = malloc(size + 1);
+ *strp = ast_malloc(size + 1);
if (!*strp)
return -1;
vsnprintf(*strp, size + 1, fmt, ap);
diff --git a/main/tdd.c b/main/tdd.c
index 7189f490e..a3ef39282 100644
--- a/main/tdd.c
+++ b/main/tdd.c
@@ -101,9 +101,8 @@ void tdd_init(void)
struct tdd_state *tdd_new(void)
{
struct tdd_state *tdd;
- tdd = malloc(sizeof(struct tdd_state));
+ tdd = calloc(1, sizeof(*tdd));
if (tdd) {
- memset(tdd, 0, sizeof(struct tdd_state));
tdd->fskd.spb = 176; /* 45.5 baud */
tdd->fskd.hdlc = 0; /* Async */
tdd->fskd.nbit = 5; /* 5 bits */
@@ -143,13 +142,12 @@ int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int len)
int b = 'X';
int res;
int c,x;
- short *buf = malloc(2 * len + tdd->oldlen);
+ short *buf = calloc(1, 2 * len + tdd->oldlen);
short *obuf = buf;
if (!buf) {
ast_log(LOG_WARNING, "Out of memory\n");
return -1;
}
- memset(buf, 0, 2 * len + tdd->oldlen);
memcpy(buf, tdd->oldstuff, tdd->oldlen);
mylen += tdd->oldlen/2;
for (x = 0; x < len; x++)
diff --git a/main/threadstorage.c b/main/threadstorage.c
index b481343df..26f3e1c19 100644
--- a/main/threadstorage.c
+++ b/main/threadstorage.c
@@ -85,7 +85,7 @@ void __ast_threadstorage_object_remove(void *key)
AST_LIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&tls_objects);
if (to)
- free(to);
+ ast_free(to);
}
void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len)
diff --git a/main/translate.c b/main/translate.c
index f13f62746..b80c280de 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -129,7 +129,7 @@ static void *newpvt(struct ast_translator *t)
pvt->outbuf = ofs + AST_FRIENDLY_OFFSET;
/* call local init routine, if present */
if (t->newpvt && t->newpvt(pvt)) {
- free(pvt);
+ ast_free(pvt);
return NULL;
}
ast_module_ref(t->module);
@@ -142,7 +142,7 @@ static void destroy(struct ast_trans_pvt *pvt)
if (t->destroy)
t->destroy(pvt);
- free(pvt);
+ ast_free(pvt);
ast_module_unref(t->module);
}
diff --git a/main/udptl.c b/main/udptl.c
index d255f9375..34b5b872f 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -824,7 +824,7 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struc
udptl->us.sin_family = AF_INET;
if ((udptl->fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- free(udptl);
+ ast_free(udptl);
ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno));
return NULL;
}
@@ -845,7 +845,7 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struc
if (errno != EADDRINUSE) {
ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno));
close(udptl->fd);
- free(udptl);
+ ast_free(udptl);
return NULL;
}
if (++x > udptlend)
@@ -853,7 +853,7 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struc
if (x == startplace) {
ast_log(LOG_WARNING, "No UDPTL ports remaining\n");
close(udptl->fd);
- free(udptl);
+ ast_free(udptl);
return NULL;
}
}
@@ -908,7 +908,7 @@ void ast_udptl_destroy(struct ast_udptl *udptl)
ast_io_remove(udptl->io, udptl->ioid);
if (udptl->fd > -1)
close(udptl->fd);
- free(udptl);
+ ast_free(udptl);
}
int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f)
diff --git a/main/utils.c b/main/utils.c
index 498184a41..7570ca608 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -539,7 +539,7 @@ static void *dummy_start(void *data)
keep a copy of the pointer and then ast_unregister_thread will
free the memory
*/
- free(data);
+ ast_free(data);
ast_register_thread(a.name);
pthread_cleanup_push(ast_unregister_thread, (void *) pthread_self());
ret = a.start_routine(a.data);