diff --git a/configuration.c b/configuration.c index 13144762ef..9d15b4dca4 100644 --- a/configuration.c +++ b/configuration.c @@ -2424,7 +2424,7 @@ static config_file_t *open_default_config_file(void) bool saved = false; /* Try to create a new config file. */ - conf = config_file_new_null(); + conf = config_file_new_alloc(); if (conf) { @@ -2463,7 +2463,7 @@ static config_file_t *open_default_config_file(void) if (!conf) { bool saved = false; - conf = config_file_new_null(); + conf = config_file_new_alloc(); if (conf) { @@ -2535,7 +2535,7 @@ static config_file_t *open_default_config_file(void) if (conf) RARCH_WARN("Config: using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf); else - conf = config_file_new_null(); + conf = config_file_new_alloc(); free(skeleton_conf); @@ -3639,7 +3639,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user) if (!conf) { - conf = config_file_new_null(); + conf = config_file_new_alloc(); if (!conf) { free(autoconf_file); @@ -3710,7 +3710,7 @@ bool config_save_file(const char *path) int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder); if (!conf) - conf = config_file_new_null(); + conf = config_file_new_alloc(); if (!conf || rarch_ctl(RARCH_CTL_IS_OVERRIDES_ACTIVE, NULL)) { @@ -3993,7 +3993,7 @@ bool config_save_overrides(int override_type) path_size); if (!conf) - conf = config_file_new_null(); + conf = config_file_new_alloc(); /* Load the original config file in memory */ config_load_file(path_get(RARCH_PATH_CONFIG), settings); diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index 782ff5f32b..105f778e44 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -156,7 +156,7 @@ static void salamander_init(char *s, size_t len) if (!config_exists) { - config_file_t *conf = (config_file_t*)config_file_new_null(); + config_file_t *conf = (config_file_t*)config_file_new_alloc(); if (conf) { diff --git a/input/input_remapping.c b/input/input_remapping.c index 996703b0d8..25857ba935 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -170,7 +170,7 @@ bool input_remapping_save_file(const char *path) if (!conf) { - if (!(conf = config_file_new_null())) + if (!(conf = config_file_new_alloc())) { free(remap_file); return false; diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 192b2ef857..cb55f363bb 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -396,17 +396,7 @@ static config_file_t *config_file_new_internal( const char *path, unsigned depth, config_file_cb_t *cb) { RFILE *file = NULL; - struct config_file *conf = (struct config_file*)malloc(sizeof(*conf)); - if (!conf) - return NULL; - - conf->path = NULL; - conf->entries = NULL; - conf->tail = NULL; - conf->last = NULL; - conf->includes = NULL; - conf->include_depth = 0; - conf->guaranteed_no_duplicates = false ; + struct config_file *conf = config_file_new_alloc(); if (!path || !*path) return conf; @@ -614,7 +604,7 @@ config_file_t *config_file_new(const char *path) return config_file_new_internal(path, 0, NULL); } -config_file_t *config_file_new_null(void) +config_file_t *config_file_new_alloc(void) { struct config_file *conf = (struct config_file*)malloc(sizeof(*conf)); if (!conf) diff --git a/libretro-common/include/file/config_file.h b/libretro-common/include/file/config_file.h index 9e682cfaa2..ed3124265a 100644 --- a/libretro-common/include/file/config_file.h +++ b/libretro-common/include/file/config_file.h @@ -86,7 +86,7 @@ typedef struct config_file_cb config_file_cb_t ; * NULL path will create an empty config file. */ config_file_t *config_file_new(const char *path); -config_file_t *config_file_new_null(void); +config_file_t *config_file_new_alloc(void); /* Loads a config file. Returns NULL if file doesn't exist. * NULL path will create an empty config file. diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index 9c92e3d661..731a70c0da 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -168,7 +168,7 @@ bool cheat_manager_save(const char *path, const char *cheat_database, bool overw conf = config_file_new(cheats_file); if (!conf) - if (!(conf = config_file_new_null())) + if (!(conf = config_file_new_alloc())) return false; conf->guaranteed_no_duplicates = true; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 044897dad3..db13b7c906 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4037,7 +4037,7 @@ static int action_ok_option_create(const char *path, conf = config_file_new(game_path); if (!conf) - if (!(conf = config_file_new_null())) + if (!(conf = config_file_new_alloc())) return false; if (config_file_write(conf, game_path, true)) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 8358358e95..ae4df7e23c 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -357,7 +357,7 @@ bool menu_shader_manager_save_preset( dirs[2] = config_directory; } - if (!(conf = (config_file_t*)config_file_new_null())) + if (!(conf = (config_file_t*)config_file_new_alloc())) return false; if (fullpath) diff --git a/retroarch.c b/retroarch.c index 07103fd273..3ba5294b40 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2086,13 +2086,11 @@ static core_option_manager_t *core_option_manager_new_vars(const char *conf_path } if (!opt->conf) - opt->conf = config_file_new_null(); + if (!(opt->conf = config_file_new_alloc())) + goto error; strlcpy(opt->conf_path, conf_path, sizeof(opt->conf_path)); - if (!opt->conf) - goto error; - for (var = vars; var->key && var->value; var++) size++; @@ -2154,13 +2152,11 @@ static core_option_manager_t *core_option_manager_new(const char *conf_path, } if (!opt->conf) - opt->conf = config_file_new_null(); + if (!(opt->conf = config_file_new_alloc())) + goto error; strlcpy(opt->conf_path, conf_path, sizeof(opt->conf_path)); - if (!opt->conf) - goto error; - /* Note: 'option_def->info == NULL' is valid */ for (option_def = option_defs; option_def->key && option_def->desc && option_def->values[0].value; diff --git a/ui/drivers/qt/coreoptionsdialog.cpp b/ui/drivers/qt/coreoptionsdialog.cpp index ee61bd2700..e7dce9e8eb 100644 --- a/ui/drivers/qt/coreoptionsdialog.cpp +++ b/ui/drivers/qt/coreoptionsdialog.cpp @@ -137,7 +137,7 @@ void CoreOptionsDialog::onSaveGameSpecificOptions() if (!conf) { - if (!(conf = config_file_new_null())) + if (!(conf = config_file_new_alloc())) { QMessageBox::critical(this, msg_hash_to_str(MSG_ERROR), msg_hash_to_str(MSG_ERROR_SAVING_CORE_OPTIONS_FILE)); return;