diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index f182c62cba..c5bad34073 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -574,14 +574,11 @@ error: return NULL; } -void config_file_free(config_file_t *conf) +static void config_file_deinitialize_internal(config_file_t *conf) { struct config_include_list *inc_tmp = NULL; - struct config_entry_list *tmp = NULL; - if (!conf) - return; + struct config_entry_list *tmp = conf->entries; - tmp = conf->entries; while (tmp) { struct config_entry_list *hold = NULL; @@ -614,9 +611,24 @@ void config_file_free(config_file_t *conf) if (conf->path) free(conf->path); +} + +void config_file_free(config_file_t *conf) +{ + if (!conf) + return; + config_file_deinitialize_internal(conf); free(conf); } +bool config_file_deinitialize(config_file_t *conf) +{ + if (!conf) + return false; + config_file_deinitialize_internal(conf); + return true; +} + bool config_append_file(config_file_t *conf, const char *path) { config_file_t *new_conf = config_file_new_from_path_to_string(path); diff --git a/libretro-common/include/file/config_file.h b/libretro-common/include/file/config_file.h index 4f224c8940..b19539f18a 100644 --- a/libretro-common/include/file/config_file.h +++ b/libretro-common/include/file/config_file.h @@ -105,6 +105,8 @@ config_file_t *config_file_new_from_path_to_string(const char *path); /* Frees config file. */ void config_file_free(config_file_t *conf); +bool config_file_deinitialize(config_file_t *conf); + /* Loads a new config, and appends its data to conf. * The key-value pairs of the new config file takes priority over the old. */ bool config_append_file(config_file_t *conf, const char *path);