mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
Issue 9869 - replace malloc and memset with ast_calloc, and other coding guidelines changes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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;
|
||||
|
@@ -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");
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user