Use malloc instead of calloc where possible

This commit is contained in:
twinaphex 2020-06-24 19:27:02 +02:00
parent 7cac61e5eb
commit f5940ed188
3 changed files with 12 additions and 9 deletions

View File

@ -421,13 +421,14 @@ bool input_autoconfigure_disconnect(unsigned i, const char *ident)
{
char msg[255];
retro_task_t *task = task_init();
autoconfig_disconnect_t *state = (autoconfig_disconnect_t*)calloc(1, sizeof(*state));
autoconfig_disconnect_t *state = (autoconfig_disconnect_t*)malloc(sizeof(*state));
if (!state || !task)
goto error;
msg[0] = '\0';
state->msg = NULL;
state->idx = i;
snprintf(msg, sizeof(msg), "%s #%u (%s).",
@ -499,7 +500,7 @@ void input_autoconfigure_connect(
{
unsigned i;
retro_task_t *task = task_init();
autoconfig_params_t *state = (autoconfig_params_t*)calloc(1, sizeof(*state));
autoconfig_params_t *state = (autoconfig_params_t*)malloc(sizeof(*state));
settings_t *settings = config_get_ptr();
const char *dir_autoconf = settings ? settings->paths.directory_autoconfig : NULL;
bool autodetect_enable = settings ? settings->bools.input_autodetect_enable : false;
@ -518,6 +519,14 @@ void input_autoconfigure_connect(
return;
}
state->vid = vid;
state->pid = pid;
state->idx = idx;
state->max_users = *(
input_driver_get_uint(INPUT_ACTION_MAX_USERS));
state->name = NULL;
state->autoconfig_directory = NULL;
if (!string_is_empty(name))
state->name = strdup(name);
@ -525,11 +534,6 @@ void input_autoconfigure_connect(
state->autoconfig_directory = strdup(dir_autoconf);
state->show_hidden_files = settings->bools.show_hidden_files;
state->idx = idx;
state->vid = vid;
state->pid = pid;
state->max_users = *(
input_driver_get_uint(INPUT_ACTION_MAX_USERS));
#ifdef HAVE_BLISSBOX
if (state->vid == BLISSBOX_VID)

View File

@ -1378,7 +1378,6 @@ bool task_push_dbscan(
#endif
db->show_hidden_files = db_dir_show_hidden_files;
db->is_directory = directory;
db->playlist_directory = NULL;
db->fullpath = strdup(fullpath);
db->playlist_directory = strdup(playlist_directory);
db->content_database_path = strdup(content_database);

View File

@ -197,7 +197,7 @@ task_finished:
}
else
{
data = (http_transfer_data_t*)calloc(1, sizeof(*data));
data = (http_transfer_data_t*)malloc(sizeof(*data));
data->data = tmp;
data->len = len;