aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-06 21:20:11 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-06 21:20:11 +0000
commiteb5d461ed4688cafadc76bebf329a2fae454dc12 (patch)
tree5503cb153c9de46c07e3a0a521cc996926ed375b /apps
parent125558c76fd4870a9133e4974cce6410c89a3593 (diff)
Issue 9869 - replace malloc and memset with ast_calloc, and other coding guidelines changes
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@67864 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_adsiprog.c12
-rw-r--r--apps/app_alarmreceiver.c2
-rw-r--r--apps/app_dial.c8
-rw-r--r--apps/app_directory.c12
-rw-r--r--apps/app_externalivr.c10
-rw-r--r--apps/app_festival.c4
-rw-r--r--apps/app_followme.c18
-rw-r--r--apps/app_macro.c10
-rw-r--r--apps/app_meetme.c52
-rw-r--r--apps/app_milliwatt.c2
-rw-r--r--apps/app_minivm.c28
-rw-r--r--apps/app_mixmonitor.c6
-rw-r--r--apps/app_osplookup.c24
-rw-r--r--apps/app_queue.c34
-rw-r--r--apps/app_readfile.c2
-rw-r--r--apps/app_rpt.c12
-rw-r--r--apps/app_speech_utils.c2
-rw-r--r--apps/app_voicemail.c21
18 files changed, 129 insertions, 130 deletions
diff --git a/apps/app_adsiprog.c b/apps/app_adsiprog.c
index 40330152b..b07a950a2 100644
--- a/apps/app_adsiprog.c
+++ b/apps/app_adsiprog.c
@@ -1384,11 +1384,11 @@ static struct adsi_script *compile_script(char *script)
break;
case STATE_INSUB:
ast_log(LOG_WARNING, "Missing ENDSUB at end of file %s\n", script);
- free(scr);
+ ast_free(scr);
return NULL;
case STATE_INKEY:
ast_log(LOG_WARNING, "Missing ENDKEY at end of file %s\n", script);
- free(scr);
+ ast_free(scr);
return NULL;
}
err = 0;
@@ -1414,7 +1414,7 @@ static struct adsi_script *compile_script(char *script)
}
if (err) {
- free(scr);
+ ast_free(scr);
return NULL;
}
return scr;
@@ -1451,7 +1451,7 @@ static int adsi_prog(struct ast_channel *chan, char *script)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "User rejected download attempt\n");
ast_log(LOG_NOTICE, "User rejected download on channel %s\n", chan->name);
- free(scr);
+ ast_free(scr);
return -1;
}
@@ -1538,10 +1538,10 @@ static int adsi_prog(struct ast_channel *chan, char *script)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Download attempt failed\n");
ast_log(LOG_NOTICE, "Download failed on %s\n", chan->name);
- free(scr);
+ ast_free(scr);
return -1;
}
- free(scr);
+ ast_free(scr);
ast_adsi_unload_session(chan);
return 0;
}
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index e74a7b46a..56f604f27 100644
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -727,7 +727,7 @@ static int alarmreceiver_exec(struct ast_channel *chan, void *data)
for(elp = event_head; (elp != NULL);){
efree = elp;
elp = elp->next;
- free(efree);
+ ast_free(efree);
}
diff --git a/apps/app_dial.c b/apps/app_dial.c
index f713f3375..0d30dc118 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -312,7 +312,7 @@ static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception)
ast_hangup(outgoing->chan);
oo = outgoing;
outgoing=outgoing->next;
- free(oo);
+ ast_free(oo);
}
}
@@ -1327,7 +1327,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
handle_cause(cause, &num);
if (!rest) /* we are on the last destination */
chan->hangupcause = cause;
- free(tmp);
+ ast_free(tmp);
continue;
}
pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);
@@ -1374,7 +1374,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
}
if (!tc) {
handle_cause(cause, &num);
- free(tmp);
+ ast_free(tmp);
continue;
}
}
@@ -1436,7 +1436,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", numsubst);
ast_hangup(tc);
tc = NULL;
- free(tmp);
+ ast_free(tmp);
continue;
} else {
senddialevent(chan, tc);
diff --git a/apps/app_directory.c b/apps/app_directory.c
index 8a62c65eb..0346d6452 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -463,14 +463,14 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, struct
if (!strncmp(conv, ext, strlen(ext))) {
/* Match! */
found++;
- free(conv);
- free(start);
+ ast_free(conv);
+ ast_free(start);
break;
}
- free(conv);
+ ast_free(conv);
}
}
- free(start);
+ ast_free(start);
}
v = v->next;
}
@@ -547,10 +547,10 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, struct
default:
break;
}
- free(conv);
+ ast_free(conv);
break;
}
- free(conv);
+ ast_free(conv);
}
}
}
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index 7f2071630..f08e42ac2 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -136,7 +136,7 @@ static void gen_release(struct ast_channel *chan, void *data)
struct gen_state *state = data;
gen_closestream(state);
- free(data);
+ ast_free(data);
}
/* caller has the playlist locked */
@@ -399,7 +399,7 @@ static int app_exec(struct ast_channel *chan, void *data)
AST_LIST_LOCK(&u->finishlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->finishlist, list))) {
send_child_event(child_events, 'F', entry->filename, chan);
- free(entry);
+ ast_free(entry);
}
AST_LIST_UNLOCK(&u->finishlist);
}
@@ -422,7 +422,7 @@ static int app_exec(struct ast_channel *chan, void *data)
AST_LIST_LOCK(&u->playlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_child_event(child_events, 'D', entry->filename, chan);
- free(entry);
+ ast_free(entry);
}
if (!u->playing_silence)
u->abort_current_sound = 1;
@@ -467,7 +467,7 @@ static int app_exec(struct ast_channel *chan, void *data)
AST_LIST_LOCK(&u->playlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_child_event(child_events, 'D', entry->filename, chan);
- free(entry);
+ ast_free(entry);
}
if (!u->playing_silence)
u->abort_current_sound = 1;
@@ -569,7 +569,7 @@ static int app_exec(struct ast_channel *chan, void *data)
close(child_stderr[1]);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list)))
- free(entry);
+ ast_free(entry);
ast_module_user_remove(lu);
diff --git a/apps/app_festival.c b/apps/app_festival.c
index 22a799f63..dbc9d6244 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -525,7 +525,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
ast_log(LOG_DEBUG,"Festival WV command\n");
waveform = socket_receive_file_to_buff(fd,&filesize);
res = send_waveform_to_channel(chan,waveform,filesize, intstr);
- free(waveform);
+ ast_free(waveform);
break;
}
else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */
@@ -534,7 +534,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
waveform = socket_receive_file_to_buff(fd,&filesize);
waveform[filesize]='\0';
ast_log(LOG_WARNING,"Festival returned LP : %s\n",waveform);
- free(waveform);
+ ast_free(waveform);
} else if (strcmp(ack,"ER\n") == 0) { /* server got an error */
ast_log(LOG_WARNING,"Festival returned ER\n");
res=-1;
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 2e313d012..37c81d136 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -172,17 +172,17 @@ static void free_numbers(struct call_followme *f)
while ((prev = AST_LIST_REMOVE_HEAD(&f->numbers, entry)))
/* Free the number */
- free(prev);
+ ast_free(prev);
AST_LIST_HEAD_INIT_NOLOCK(&f->numbers);
while ((prev = AST_LIST_REMOVE_HEAD(&f->blnumbers, entry)))
/* Free the blacklisted number */
- free(prev);
+ ast_free(prev);
AST_LIST_HEAD_INIT_NOLOCK(&f->blnumbers);
while ((prev = AST_LIST_REMOVE_HEAD(&f->wlnumbers, entry)))
/* Free the whitelisted number */
- free(prev);
+ ast_free(prev);
AST_LIST_HEAD_INIT_NOLOCK(&f->wlnumbers);
}
@@ -815,7 +815,7 @@ static void findmeexec(struct fm_args *tpargs)
tmpuser = ast_calloc(1, sizeof(*tmpuser));
if (!tmpuser) {
ast_log(LOG_WARNING, "Out of memory!\n");
- free(findme_user_list);
+ ast_free(findme_user_list);
return;
}
@@ -872,7 +872,7 @@ static void findmeexec(struct fm_args *tpargs)
if (!fmuser->cleared && fmuser->ochan != winner)
clear_caller(fmuser);
AST_LIST_REMOVE_CURRENT(findme_user_list, entry);
- free(fmuser);
+ ast_free(fmuser);
}
AST_LIST_TRAVERSE_SAFE_END
fmuser = NULL;
@@ -883,7 +883,7 @@ static void findmeexec(struct fm_args *tpargs)
if (!caller) {
tpargs->status = 1;
- free(findme_user_list);
+ ast_free(findme_user_list);
return;
}
@@ -893,7 +893,7 @@ static void findmeexec(struct fm_args *tpargs)
break;
}
- free(findme_user_list);
+ ast_free(findme_user_list);
if (!winner)
tpargs->status = 1;
else {
@@ -1012,7 +1012,7 @@ static int app_exec(struct ast_channel *chan, void *data)
AST_LIST_TRAVERSE_SAFE_BEGIN(&targs.cnumbers, nm, entry) {
AST_LIST_REMOVE_CURRENT(&targs.cnumbers, entry);
- free(nm);
+ ast_free(nm);
}
AST_LIST_TRAVERSE_SAFE_END
@@ -1075,7 +1075,7 @@ static int unload_module(void)
AST_LIST_LOCK(&followmes);
while ((f = AST_LIST_REMOVE_HEAD(&followmes, entry))) {
free_numbers(f);
- free(f);
+ ast_free(f);
}
AST_LIST_UNLOCK(&followmes);
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 625c4543f..21f65f1ab 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -422,7 +422,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
if (oldargs[x]) {
if (!dead)
pbx_builtin_setvar_helper(chan, varname, oldargs[x]);
- free(oldargs[x]);
+ ast_free(oldargs[x]);
} else if (!dead) {
pbx_builtin_setvar_helper(chan, varname, NULL);
}
@@ -435,11 +435,11 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
}
if (save_macro_exten)
- free(save_macro_exten);
+ ast_free(save_macro_exten);
if (save_macro_context)
- free(save_macro_context);
+ ast_free(save_macro_context);
if (save_macro_priority)
- free(save_macro_priority);
+ ast_free(save_macro_priority);
if (!dead && setmacrocontext) {
chan->macrocontext[0] = '\0';
@@ -470,7 +470,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
if (!dead)
pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset);
if (save_macro_offset)
- free(save_macro_offset);
+ ast_free(save_macro_offset);
/* Unlock the macro */
if (exclusive) {
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 91d590256..98510667f 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -765,7 +765,7 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
cnf->fd = open("/dev/zap/pseudo", O_RDWR);
if (cnf->fd < 0) {
ast_log(LOG_WARNING, "Unable to open pseudo device\n");
- free(cnf);
+ ast_free(cnf);
cnf = NULL;
goto cnfout;
}
@@ -780,7 +780,7 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
ast_hangup(cnf->chan);
else
close(cnf->fd);
- free(cnf);
+ ast_free(cnf);
cnf = NULL;
goto cnfout;
}
@@ -1247,7 +1247,7 @@ static int conf_free(struct ast_conference *conf)
else
close(conf->fd);
- free(conf);
+ ast_free(conf);
return 0;
}
@@ -2278,7 +2278,7 @@ bailoutandtrynormal:
snprintf(meetmesecs, sizeof(meetmesecs), "%d", (int) (time(NULL) - user->jointime));
pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs);
}
- free(user);
+ ast_free(user);
AST_LIST_UNLOCK(&confs);
return ret;
@@ -3348,9 +3348,9 @@ static void sla_stop_ringing_trunk(struct sla_ringing_trunk *ringing_trunk)
sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
while ((station_ref = AST_LIST_REMOVE_HEAD(&ringing_trunk->timed_out_stations, entry)))
- free(station_ref);
+ ast_free(station_ref);
- free(ringing_trunk);
+ ast_free(ringing_trunk);
}
static void sla_stop_ringing_station(struct sla_ringing_station *ringing_station,
@@ -3385,7 +3385,7 @@ static void sla_stop_ringing_station(struct sla_ringing_station *ringing_station
}
done:
- free(ringing_station);
+ ast_free(ringing_station);
}
static void sla_dial_state_callback(struct ast_dial *dial)
@@ -3496,8 +3496,8 @@ static void sla_handle_dial_state_event(void)
args.station = ringing_station->station;
args.cond = &cond;
args.cond_lock = &cond_lock;
- free(ringing_trunk);
- free(ringing_station);
+ ast_free(ringing_trunk);
+ ast_free(ringing_station);
ast_mutex_init(&cond_lock);
ast_cond_init(&cond, NULL);
ast_mutex_lock(&cond_lock);
@@ -3551,7 +3551,7 @@ static int sla_check_failed_station(const struct sla_station *station)
continue;
if (ast_tvdiff_ms(ast_tvnow(), failed_station->last_try) > 1000) {
AST_LIST_REMOVE_CURRENT(&sla.failed_stations, entry);
- free(failed_station);
+ ast_free(failed_station);
break;
}
res = 1;
@@ -3586,12 +3586,12 @@ static int sla_ring_station(struct sla_ringing_trunk *ringing_trunk, struct sla_
if (!sla.attempt_callerid && !ast_strlen_zero(ringing_trunk->trunk->chan->cid.cid_name)) {
cid_name = ast_strdupa(ringing_trunk->trunk->chan->cid.cid_name);
- free(ringing_trunk->trunk->chan->cid.cid_name);
+ ast_free(ringing_trunk->trunk->chan->cid.cid_name);
ringing_trunk->trunk->chan->cid.cid_name = NULL;
}
if (!sla.attempt_callerid && !ast_strlen_zero(ringing_trunk->trunk->chan->cid.cid_num)) {
cid_num = ast_strdupa(ringing_trunk->trunk->chan->cid.cid_num);
- free(ringing_trunk->trunk->chan->cid.cid_num);
+ ast_free(ringing_trunk->trunk->chan->cid.cid_num);
ringing_trunk->trunk->chan->cid.cid_num = NULL;
}
@@ -3753,7 +3753,7 @@ static void sla_hangup_stations(void)
ast_dial_join(ringing_station->station->dial);
ast_dial_destroy(ringing_station->station->dial);
ringing_station->station->dial = NULL;
- free(ringing_station);
+ ast_free(ringing_station);
}
}
AST_LIST_TRAVERSE_SAFE_END
@@ -4018,7 +4018,7 @@ static void *sla_thread(void *data)
sla_handle_ringing_trunk_event();
break;
}
- free(event);
+ ast_free(event);
ast_mutex_lock(&sla.lock);
}
}
@@ -4026,10 +4026,10 @@ static void *sla_thread(void *data)
ast_mutex_unlock(&sla.lock);
while ((ringing_station = AST_LIST_REMOVE_HEAD(&sla.ringing_stations, entry)))
- free(ringing_station);
+ ast_free(ringing_station);
while ((failed_station = AST_LIST_REMOVE_HEAD(&sla.failed_stations, entry)))
- free(failed_station);
+ ast_free(failed_station);
return NULL;
}
@@ -4072,12 +4072,12 @@ static void *dial_trunk(void *data)
if (!sla.attempt_callerid && !ast_strlen_zero(trunk_ref->chan->cid.cid_name)) {
cid_name = ast_strdupa(trunk_ref->chan->cid.cid_name);
- free(trunk_ref->chan->cid.cid_name);
+ ast_free(trunk_ref->chan->cid.cid_name);
trunk_ref->chan->cid.cid_name = NULL;
}
if (!sla.attempt_callerid && !ast_strlen_zero(trunk_ref->chan->cid.cid_num)) {
cid_num = ast_strdupa(trunk_ref->chan->cid.cid_num);
- free(trunk_ref->chan->cid.cid_num);
+ ast_free(trunk_ref->chan->cid.cid_num);
trunk_ref->chan->cid.cid_num = NULL;
}
@@ -4389,7 +4389,7 @@ static int sla_trunk_exec(struct ast_channel *chan, void *data)
ast_mutex_unlock(&sla.lock);
if (ringing_trunk) {
sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
- free(ringing_trunk);
+ ast_free(ringing_trunk);
pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "UNANSWERED");
/* Queue reprocessing of ringing trunks to make stations stop ringing
* that shouldn't be ringing after this trunk stopped. */
@@ -4457,10 +4457,10 @@ static void destroy_trunk(struct sla_trunk *trunk)
ast_context_remove_extension(trunk->autocontext, "s", 1, sla_registrar);
while ((station_ref = AST_LIST_REMOVE_HEAD(&trunk->stations, entry)))
- free(station_ref);
+ ast_free(station_ref);
ast_string_field_free_all(trunk);
- free(trunk);
+ ast_free(trunk);
}
static void destroy_station(struct sla_station *station)
@@ -4483,10 +4483,10 @@ static void destroy_station(struct sla_station *station)
}
while ((trunk_ref = AST_LIST_REMOVE_HEAD(&station->trunks, entry)))
- free(trunk_ref);
+ ast_free(trunk_ref);
ast_string_field_free_all(station);
- free(station);
+ ast_free(station);
}
static void sla_destroy(void)
@@ -4549,7 +4549,7 @@ static int sla_build_trunk(struct ast_config *cfg, const char *cat)
if (!(trunk = ast_calloc(1, sizeof(*trunk))))
return -1;
if (ast_string_field_init(trunk, 32)) {
- free(trunk);
+ ast_free(trunk);
return -1;
}
@@ -4654,7 +4654,7 @@ static void sla_add_trunk_to_station(struct sla_station *station, struct ast_var
}
if (!(station_ref = sla_create_station_ref(station))) {
- free(trunk_ref);
+ ast_free(trunk_ref);
return;
}
ast_atomic_fetchadd_int((int *) &trunk->num_stations, 1);
@@ -4678,7 +4678,7 @@ static int sla_build_station(struct ast_config *cfg, const char *cat)
if (!(station = ast_calloc(1, sizeof(*station))))
return -1;
if (ast_string_field_init(station, 32)) {
- free(station);
+ ast_free(station);
return -1;
}
diff --git a/apps/app_milliwatt.c b/apps/app_milliwatt.c
index 5a2a9e18d..31ded36d6 100644
--- a/apps/app_milliwatt.c
+++ b/apps/app_milliwatt.c
@@ -59,7 +59,7 @@ static void *milliwatt_alloc(struct ast_channel *chan, void *params)
static void milliwatt_release(struct ast_channel *chan, void *data)
{
- free(data);
+ ast_free(data);
return;
}
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index 95a2b10d8..62b589c80 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -470,7 +470,7 @@ static struct minivm_template *message_template_create(const char *name)
{
struct minivm_template *template;
- template = ast_calloc(1, sizeof(struct minivm_template));
+ template = ast_calloc(1, sizeof(*template));
if (!template)
return NULL;
@@ -488,9 +488,9 @@ static struct minivm_template *message_template_create(const char *name)
static void message_template_free(struct minivm_template *template)
{
if (template->body)
- free(template->body);
+ ast_free(template->body);
- free (template);
+ ast_free (template);
}
/*! \brief Build message template from configuration */
@@ -524,7 +524,7 @@ static int message_template_build(const char *name, struct ast_variable *var)
ast_copy_string(template->charset, var->value, sizeof(template->charset));
} else if (!strcasecmp(var->name, "templatefile")) {
if (template->body)
- free(template->body);
+ ast_free(template->body);
template->body = message_template_parse_filebody(var->value);
if (!template->body) {
ast_log(LOG_ERROR, "Error reading message body definition file %s\n", var->value);
@@ -532,7 +532,7 @@ static int message_template_build(const char *name, struct ast_variable *var)
}
} else if (!strcasecmp(var->name, "messagebody")) {
if (template->body)
- free(template->body);
+ ast_free(template->body);
template->body = message_template_parse_emailbody(var->value);
if (!template->body) {
ast_log(LOG_ERROR, "Error parsing message body definition:\n %s\n", var->value);
@@ -727,7 +727,7 @@ static void free_user(struct minivm_account *vmu)
{
if (vmu->chanvars)
ast_variables_destroy(vmu->chanvars);
- free(vmu);
+ ast_free(vmu);
}
@@ -793,7 +793,7 @@ static struct minivm_account *mvm_user_alloc(void)
{
struct minivm_account *new;
- new = calloc(1, sizeof(struct minivm_account));
+ new = ast_calloc(1, sizeof(*new));
if (!new)
return NULL;
populate_defaults(new);
@@ -808,7 +808,7 @@ static void vmaccounts_destroy_list(void)
struct minivm_account *this;
AST_LIST_LOCK(&minivm_accounts);
while ((this = AST_LIST_REMOVE_HEAD(&minivm_accounts, list)))
- free(this);
+ ast_free(this);
AST_LIST_UNLOCK(&minivm_accounts);
}
@@ -877,7 +877,7 @@ static struct minivm_account *find_user_realtime(const char *domain, const char
var = ast_load_realtime("minivm", "username", username, "domain", domain, NULL);
if (!var) {
- free(retval);
+ ast_free(retval);
return NULL;
}
@@ -2201,7 +2201,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime)
ast_log(LOG_DEBUG, "Creating static account for user %s domain %s\n", username, domain);
/* Allocate user account */
- vmu = ast_calloc(1, sizeof(struct minivm_account));
+ vmu = ast_calloc(1, sizeof(*vmu));
if (!vmu)
return 0;
@@ -2277,7 +2277,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime)
/*! \brief Free Mini Voicemail timezone */
static void free_zone(struct minivm_zone *z)
{
- free(z);
+ ast_free(z);
}
/*! \brief Clear list of timezones */
@@ -2299,21 +2299,21 @@ static int timezone_add(char *zonename, char *config)
struct minivm_zone *newzone;
char *msg_format, *timezone;
- newzone = ast_calloc(1, sizeof(struct minivm_zone));
+ newzone = ast_calloc(1, sizeof(*newzone));
if (newzone == NULL)
return 0;
msg_format = ast_strdupa(config);
if (msg_format == NULL) {
ast_log(LOG_WARNING, "Out of memory.\n");
- free(newzone);
+ ast_free(newzone);
return 0;
}
timezone = strsep(&msg_format, "|");
if (!msg_format) {
ast_log(LOG_WARNING, "Invalid timezone definition : %s\n", zonename);
- free(newzone);
+ ast_free(newzone);
return 0;
}
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 542d323dc..96782c537 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -220,7 +220,7 @@ static void *mixmonitor_thread(void *obj)
if (fs)
ast_closestream(fs);
- free(mixmonitor);
+ ast_free(mixmonitor);
return NULL;
@@ -253,7 +253,7 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
}
/* Pre-allocate mixmonitor structure and spy */
- if (!(mixmonitor = calloc(1, len))) {
+ if (!(mixmonitor = ast_calloc(1, len))) {
return;
}
@@ -291,7 +291,7 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
mixmonitor->spy.type, chan->name);
/* Since we couldn't add ourselves - bail out! */
ast_mutex_destroy(&mixmonitor->spy.lock);
- free(mixmonitor);
+ ast_free(mixmonitor);
return;
}
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index 59e4fb0ed..c7ff964b5 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -328,7 +328,7 @@ static int osp_create_provider(
error = OSPPUtilLoadPEMPrivateKey((unsigned char*)p->privatekey, &privatekey);
if (error != OSPC_ERR_NO_ERROR) {
ast_log(LOG_WARNING, "OSP: Unable to load privatekey '%s', error '%d'\n", p->privatekey, error);
- free(p);
+ ast_free(p);
return 0;
}
@@ -336,9 +336,9 @@ static int osp_create_provider(
if (error != OSPC_ERR_NO_ERROR) {
ast_log(LOG_WARNING, "OSP: Unable to load localcert '%s', error '%d'\n", p->localcert, error);
if (privatekey.PrivateKeyData) {
- free(privatekey.PrivateKeyData);
+ ast_free(privatekey.PrivateKeyData);
}
- free(p);
+ ast_free(p);
return 0;
}
@@ -354,16 +354,16 @@ static int osp_create_provider(
ast_log(LOG_WARNING, "OSP: Unable to load cacert '%s', error '%d'\n", p->cacerts[i], error);
for (j = 0; j < i; j++) {
if (cacerts[j].CertData) {
- free(cacerts[j].CertData);
+ ast_free(cacerts[j].CertData);
}
}
if (localcert.CertData) {
- free(localcert.CertData);
+ ast_free(localcert.CertData);
}
if (privatekey.PrivateKeyData) {
- free(privatekey.PrivateKeyData);
+ ast_free(privatekey.PrivateKeyData);
}
- free(p);
+ ast_free(p);
return 0;
}
pcacerts[i] = &cacerts[i];
@@ -394,7 +394,7 @@ static int osp_create_provider(
&p->handle);
if (error != OSPC_ERR_NO_ERROR) {
ast_log(LOG_WARNING, "OSP: Unable to create provider '%s', error '%d'\n", provider, error);
- free(p);
+ ast_free(p);
res = -1;
} else {
if (option_debug)
@@ -408,14 +408,14 @@ static int osp_create_provider(
for (i = 0; i < p->cacount; i++) {
if (cacerts[i].CertData) {
- free(cacerts[i].CertData);
+ ast_free(cacerts[i].CertData);
}
}
if (localcert.CertData) {
- free(localcert.CertData);
+ ast_free(localcert.CertData);
}
if (privatekey.PrivateKeyData) {
- free(privatekey.PrivateKeyData);
+ ast_free(privatekey.PrivateKeyData);
}
return res;
@@ -2009,7 +2009,7 @@ static int osp_unload(void)
while(p) {
next = p->next;
OSPPProviderDelete(p->handle, 0);
- free(p);
+ ast_free(p);
p = next;
}
ospproviders = NULL;
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 7d06d2df2..f0e6dae79 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -831,7 +831,7 @@ static int remove_from_interfaces(const char *interface)
if (option_debug)
ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
AST_LIST_REMOVE_CURRENT(&interfaces, list);
- free(curint);
+ ast_free(curint);
}
break;
}
@@ -848,7 +848,7 @@ static void clear_and_free_interfaces(void)
AST_LIST_LOCK(&interfaces);
while ((curint = AST_LIST_REMOVE_HEAD(&interfaces, list)))
- free(curint);
+ ast_free(curint);
AST_LIST_UNLOCK(&interfaces);
}
@@ -1076,7 +1076,7 @@ static void free_members(struct call_queue *q, int all)
else
q->members = next;
remove_from_interfaces(curm->interface);
- free(curm);
+ ast_free(curm);
} else
prev = curm;
}
@@ -1086,7 +1086,7 @@ static void destroy_queue(struct call_queue *q)
{
free_members(q, 1);
ast_mutex_destroy(&q->lock);
- free(q);
+ ast_free(q);
}
/*!\brief Reload a single queue via realtime.
@@ -1196,7 +1196,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
q->members = next_m;
}
remove_from_interfaces(m->interface);
- free(m);
+ ast_free(m);
} else {
prev_m = m;
}
@@ -1546,7 +1546,7 @@ static void hangupcalls(struct callattempt *outgoing, struct ast_channel *except
ast_hangup(outgoing->chan);
oo = outgoing;
outgoing = outgoing->q_next;
- free(oo);
+ ast_free(oo);
}
}
@@ -1747,13 +1747,13 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
tmp->chan->data = "(Outgoing Line)";
tmp->chan->whentohangup = 0;
if (tmp->chan->cid.cid_num)
- free(tmp->chan->cid.cid_num);
+ ast_free(tmp->chan->cid.cid_num);
tmp->chan->cid.cid_num = ast_strdup(qe->chan->cid.cid_num);
if (tmp->chan->cid.cid_name)
- free(tmp->chan->cid.cid_name);
+ ast_free(tmp->chan->cid.cid_name);
tmp->chan->cid.cid_name = ast_strdup(qe->chan->cid.cid_name);
if (tmp->chan->cid.cid_ani)
- free(tmp->chan->cid.cid_ani);
+ ast_free(tmp->chan->cid.cid_ani);
tmp->chan->cid.cid_ani = ast_strdup(qe->chan->cid.cid_ani);
/* Inherit specially named variables from parent channel */
@@ -2067,11 +2067,11 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
} else {
ast_channel_inherit_variables(in, o->chan);
if (o->chan->cid.cid_num)
- free(o->chan->cid.cid_num);
+ ast_free(o->chan->cid.cid_num);
o->chan->cid.cid_num = ast_strdup(in->cid.cid_num);
if (o->chan->cid.cid_name)
- free(o->chan->cid.cid_name);
+ ast_free(o->chan->cid.cid_name);
o->chan->cid.cid_name = ast_strdup(in->cid.cid_name);
ast_string_field_set(o->chan, accountcode, in->accountcode);
@@ -2079,11 +2079,11 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
if (in->cid.cid_ani) {
if (o->chan->cid.cid_ani)
- free(o->chan->cid.cid_ani);
+ ast_free(o->chan->cid.cid_ani);
o->chan->cid.cid_ani = ast_strdup(in->cid.cid_ani);
}
if (o->chan->cid.cid_rdnis)
- free(o->chan->cid.cid_rdnis);
+ ast_free(o->chan->cid.cid_rdnis);
o->chan->cid.cid_rdnis = ast_strdup(S_OR(in->macroexten, in->exten));
if (ast_call(o->chan, tmpchan, 0)) {
ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
@@ -2547,7 +2547,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
if (outgoing->chan && (outgoing->chan->_state == AST_STATE_UP))
break;
} else {
- free(tmp);
+ ast_free(tmp);
}
}
if (qe->expire && (!qe->parent->timeout || (qe->expire - now) <= qe->parent->timeout))
@@ -2964,7 +2964,7 @@ static int remove_from_queue(const char *queuename, const char *interface)
"Location: %s\r\n"
"MemberName: %s\r\n",
q->name, last_member->interface, last_member->membername);
- free(last_member);
+ ast_free(last_member);
if (queue_persistent_members)
dump_queue_members(q);
@@ -4087,7 +4087,7 @@ static int reload_queues(void)
} else {
q->members = newm;
}
- free(cur);
+ ast_free(cur);
} else {
/* Add them to the master int list if necessary */
add_to_interfaces(interface);
@@ -4116,7 +4116,7 @@ static int reload_queues(void)
q->members = next;
remove_from_interfaces(cur->interface);
- free(cur);
+ ast_free(cur);
}
if (new) {
diff --git a/apps/app_readfile.c b/apps/app_readfile.c
index 7e43a3806..62221570c 100644
--- a/apps/app_readfile.c
+++ b/apps/app_readfile.c
@@ -94,7 +94,7 @@ static int readfile_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "%s is longer than %d, and %d \n", file, len, (int)strlen(returnvar));
}
pbx_builtin_setvar_helper(chan, varname, returnvar);
- free(returnvar);
+ ast_free(returnvar);
}
ast_module_user_remove(u);
return res;
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index e59a7bbb5..cfded49c9 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -1353,7 +1353,7 @@ static int rpt_do_lstats(int fd, int argc, char *argv[])
l = l->next;
continue;
}
- if ((s = (struct rpt_lstat *) ast_calloc(1, sizeof(struct rpt_lstat))) == NULL) {
+ if ((s = ast_calloc(1, sizeof(*s))) == NULL) {
ast_log(LOG_ERROR, "Malloc failed in rpt_do_lstats\n");
rpt_mutex_unlock(&myrpt->lock); /* UNLOCK */
return RESULT_FAILURE;
@@ -2186,7 +2186,7 @@ static void *rpt_tele_thread(void *this)
l = l->next;
continue;
}
- m = ast_malloc(sizeof(struct rpt_link));
+ m = ast_malloc(sizeof(*m));
if (!m) {
ast_log(LOG_WARNING, "Cannot alloc memory on %s\n", mychannel->name);
remque((struct qelem *)mytele);
@@ -2453,7 +2453,7 @@ static void rpt_telemetry(struct rpt *myrpt, int mode, void *data)
struct rpt_link *mylink = (struct rpt_link *) data;
int res;
- tele = ast_calloc(1, sizeof(struct rpt_tele));
+ tele = ast_calloc(1, sizeof(*tele));
if (!tele) {
ast_log(LOG_WARNING, "Unable to allocate memory\n");
pthread_exit(NULL);
@@ -2869,7 +2869,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
rpt_mutex_unlock(&myrpt->lock);
ast_copy_string(myrpt->lastlinknode, digitbuf, MAXNODESTR);
/* establish call in monitor mode */
- l = ast_calloc(1, sizeof(struct rpt_link));
+ l = ast_calloc(1, sizeof(*l));
if (!l) {
ast_log(LOG_WARNING, "Unable to malloc\n");
return DC_ERROR;
@@ -2979,7 +2979,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
rpt_mutex_unlock(&myrpt->lock);
ast_copy_string(myrpt->lastlinknode, digitbuf, MAXNODESTR);
/* establish call in tranceive mode */
- l = ast_calloc(1, sizeof(struct rpt_link));
+ l = ast_calloc(1, sizeof(*l));
if (!l) {
ast_log(LOG_WARNING, "Unable to malloc\n");
return DC_ERROR;
@@ -6982,7 +6982,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
} else
rpt_mutex_unlock(&myrpt->lock);
/* establish call in tranceive mode */
- l = ast_calloc(1, sizeof(struct rpt_link));
+ l = ast_calloc(1, sizeof(*l));
if (!l) {
ast_log(LOG_WARNING, "Unable to malloc\n");
pthread_exit(NULL);
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 100b174d9..0956e0bab 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -511,7 +511,7 @@ static int speech_processing_sound(struct ast_channel *chan, void *data)
}
if (speech->processing_sound != NULL) {
- free(speech->processing_sound);
+ ast_free(speech->processing_sound);
speech->processing_sound = NULL;
}
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 7c1c2d9cf..750bc5a41 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -793,7 +793,7 @@ static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const cha
ast_variables_destroy(var);
} else {
if (!ivm)
- free(retval);
+ ast_free(retval);
retval = NULL;
}
}
@@ -2287,12 +2287,12 @@ static void free_user(struct ast_vm_user *vmu)
if (!ast_test_flag(vmu, VM_ALLOCED))
return;
- free(vmu);
+ ast_free(vmu);
}
static void free_zone(struct vm_zone *z)
{
- free(z);
+ ast_free(z);
}
static const char *mbox(int id)
@@ -8047,10 +8047,9 @@ static int load_config(void)
AST_LIST_UNLOCK(&zones);
} else {
ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
- free(z);
+ ast_free(z);
}
} else {
- free(z);
AST_LIST_UNLOCK(&users);
ast_config_destroy(cfg);
return -1;
@@ -8066,19 +8065,19 @@ static int load_config(void)
memset(emailtitle,0,sizeof(emailtitle));
strcpy(charset, "ISO-8859-1");
if (emailbody) {
- free(emailbody);
+ ast_free(emailbody);
emailbody = NULL;
}
if (emailsubject) {
- free(emailsubject);
+ ast_free(emailsubject);
emailsubject = NULL;
}
if (pagerbody) {
- free(pagerbody);
+ ast_free(pagerbody);
pagerbody = NULL;
}
if (pagersubject) {
- free(pagersubject);
+ ast_free(pagersubject);
pagersubject = NULL;
}
if ((s = ast_variable_retrieve(cfg, "general", "pbxskip")))
@@ -8938,7 +8937,7 @@ static struct ast_vm_user *find_user_realtime_imapuser(const char *imapuser)
ast_variables_destroy(var);
return vmu;
} else {
- free(vmu);
+ ast_free(vmu);
return NULL;
}
}
@@ -9320,7 +9319,7 @@ static void vmstate_delete(struct vm_state *vms)
AST_LIST_UNLOCK(&vmstates);
if (vc)
- free(vc);
+ ast_free(vc);
else
ast_log(LOG_ERROR, "No vmstate found for user:%s, mailbox %s\n", vms->imapuser, vms->username);
}