aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
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 /funcs
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 'funcs')
-rw-r--r--funcs/func_callerid.c4
-rw-r--r--funcs/func_curl.c2
-rw-r--r--funcs/func_devstate.c2
-rw-r--r--funcs/func_enum.c16
-rw-r--r--funcs/func_odbc.c42
-rw-r--r--funcs/func_strings.c2
6 files changed, 34 insertions, 34 deletions
diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c
index c8fd1bb9e..462f887b5 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -136,12 +136,12 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
} else if (!strncasecmp("dnid", data, 4)) {
/* do we need to lock chan here? */
if (chan->cid.cid_dnid)
- free(chan->cid.cid_dnid);
+ ast_free(chan->cid.cid_dnid);
chan->cid.cid_dnid = ast_strdup(value);
} else if (!strncasecmp("rdnis", data, 5)) {
/* do we need to lock chan here? */
if (chan->cid.cid_rdnis)
- free(chan->cid.cid_rdnis);
+ ast_free(chan->cid.cid_rdnis);
chan->cid.cid_rdnis = ast_strdup(value);
} else if (!strncasecmp("pres", data, 4)) {
int i;
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index f7b5ce75f..38c63196c 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -160,7 +160,7 @@ static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info,
chunk.memory[chunk.size - 1] = '\0';
ast_copy_string(buf, chunk.memory, len);
- free(chunk.memory);
+ ast_free(chunk.memory);
}
} else {
ast_log(LOG_ERROR, "Cannot allocate curl structure\n");
diff --git a/funcs/func_devstate.c b/funcs/func_devstate.c
index cf6070521..7125ca1b0 100644
--- a/funcs/func_devstate.c
+++ b/funcs/func_devstate.c
@@ -187,7 +187,7 @@ static int unload_module(void)
AST_RWLIST_WRLOCK(&custom_devices);
while ((dev = AST_RWLIST_REMOVE_HEAD(&custom_devices, entry)))
- free(dev);
+ ast_free(dev);
AST_RWLIST_UNLOCK(&custom_devices);
return res;
diff --git a/funcs/func_enum.c b/funcs/func_enum.c
index f0cbfba78..6e5e0c0d4 100644
--- a/funcs/func_enum.c
+++ b/funcs/func_enum.c
@@ -132,13 +132,13 @@ static void erds_destroy(struct enum_result_datastore *data)
int k;
for (k = 0; k < data->context->naptr_rrs_count; k++) {
- free(data->context->naptr_rrs[k].result);
- free(data->context->naptr_rrs[k].tech);
+ ast_free(data->context->naptr_rrs[k].result);
+ ast_free(data->context->naptr_rrs[k].tech);
}
- free(data->context->naptr_rrs);
- free(data->context);
- free(data);
+ ast_free(data->context->naptr_rrs);
+ ast_free(data->context);
+ ast_free(data);
}
static void erds_destroy_cb(void *data)
@@ -191,7 +191,7 @@ static int enum_query_read(struct ast_channel *chan, const char *cmd, char *data
goto finish;
if (!(erds->context = ast_calloc(1, sizeof(*erds->context)))) {
- free(erds);
+ ast_free(erds);
goto finish;
}
@@ -200,8 +200,8 @@ static int enum_query_read(struct ast_channel *chan, const char *cmd, char *data
snprintf(buf, len, "%u", erds->id);
if (!(datastore = ast_channel_datastore_alloc(&enum_result_datastore_info, buf))) {
- free(erds->context);
- free(erds);
+ ast_free(erds->context);
+ ast_free(erds);
goto finish;
}
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index 3f22cf462..5206c2492 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -603,7 +603,7 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
ast_copy_string((*query)->sql_read, tmp, sizeof((*query)->sql_read));
if (!ast_strlen_zero((*query)->sql_read) && ast_strlen_zero((*query)->readhandle[0])) {
- free(*query);
+ ast_free(*query);
*query = NULL;
ast_log(LOG_ERROR, "There is SQL, but no ODBC class to be used for reading: %s\n", catg);
return EINVAL;
@@ -616,7 +616,7 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
ast_copy_string((*query)->sql_write, tmp, sizeof((*query)->sql_write));
if (!ast_strlen_zero((*query)->sql_write) && ast_strlen_zero((*query)->writehandle[0])) {
- free(*query);
+ ast_free(*query);
*query = NULL;
ast_log(LOG_ERROR, "There is SQL, but no ODBC class to be used for writing: %s\n", catg);
return EINVAL;
@@ -638,7 +638,7 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
(*query)->acf = ast_calloc(1, sizeof(struct ast_custom_function));
if (! (*query)->acf) {
- free(*query);
+ ast_free(*query);
*query = NULL;
return ENOMEM;
}
@@ -650,8 +650,8 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
}
if (!((*query)->acf->name)) {
- free((*query)->acf);
- free(*query);
+ ast_free((*query)->acf);
+ ast_free(*query);
*query = NULL;
return ENOMEM;
}
@@ -659,9 +659,9 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
asprintf((char **)&((*query)->acf->syntax), "%s(<arg1>[...[,<argN>]])", (*query)->acf->name);
if (!((*query)->acf->syntax)) {
- free((char *)(*query)->acf->name);
- free((*query)->acf);
- free(*query);
+ ast_free((char *)(*query)->acf->name);
+ ast_free((*query)->acf);
+ ast_free(*query);
*query = NULL;
return ENOMEM;
}
@@ -691,19 +691,19 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
"This function may only be set.\nSQL:\n%s\n",
(*query)->sql_write);
} else {
- free((char *)(*query)->acf->syntax);
- free((char *)(*query)->acf->name);
- free((*query)->acf);
- free(*query);
+ ast_free((char *)(*query)->acf->syntax);
+ ast_free((char *)(*query)->acf->name);
+ ast_free((*query)->acf);
+ ast_free(*query);
ast_log(LOG_WARNING, "Section %s was found, but there was no SQL to execute. Ignoring.\n", catg);
return EINVAL;
}
if (! ((*query)->acf->desc)) {
- free((char *)(*query)->acf->syntax);
- free((char *)(*query)->acf->name);
- free((*query)->acf);
- free(*query);
+ ast_free((char *)(*query)->acf->syntax);
+ ast_free((char *)(*query)->acf->name);
+ ast_free((*query)->acf);
+ ast_free(*query);
*query = NULL;
return ENOMEM;
}
@@ -728,14 +728,14 @@ static int free_acf_query(struct acf_odbc_query *query)
if (query) {
if (query->acf) {
if (query->acf->name)
- free((char *)query->acf->name);
+ ast_free((char *)query->acf->name);
if (query->acf->syntax)
- free((char *)query->acf->syntax);
+ ast_free((char *)query->acf->syntax);
if (query->acf->desc)
- free((char *)query->acf->desc);
- free(query->acf);
+ ast_free((char *)query->acf->desc);
+ ast_free(query->acf);
}
- free(query);
+ ast_free(query);
}
return 0;
}
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index 451c7b1f8..faf9ef024 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -191,7 +191,7 @@ static void clearvar_prefix(struct ast_channel *chan, const char *prefix)
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->varshead, var, entries) {
if (strncasecmp(prefix, ast_var_name(var), len) == 0) {
AST_LIST_REMOVE_CURRENT(&chan->varshead, entries);
- free(var);
+ ast_free(var);
}
}
AST_LIST_TRAVERSE_SAFE_END