mirror of
https://github.com/libretro/RetroArch
synced 2025-03-31 01:21:03 +00:00
Fix some memory leaks to do with overrides, pass conf to
menu_input_remapping_load
This commit is contained in:
parent
656edd4477
commit
aed8d3d1c2
@ -782,11 +782,13 @@ static bool event_save_auto_state(void)
|
|||||||
static void event_init_remapping(void)
|
static void event_init_remapping(void)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
const char *path = settings->input.remapping_path;
|
||||||
|
config_file_t *conf = config_file_new(path);
|
||||||
|
|
||||||
if (!settings->input.remap_binds_enable)
|
if (!settings->input.remap_binds_enable || !conf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
input_remapping_load_file(settings->input.remapping_path);
|
input_remapping_load_file(conf, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1859,9 +1859,9 @@ bool config_load_override(void)
|
|||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
rarch_system_info_t *info = rarch_system_info_get_ptr();
|
rarch_system_info_t *info = rarch_system_info_get_ptr();
|
||||||
|
|
||||||
if (!global || !settings )
|
if (!global || !settings || !info)
|
||||||
{
|
{
|
||||||
RARCH_ERR("Could not obtain global pointer or configuration file pointer to retrieve path of retroarch.cfg.\n");
|
RARCH_ERR("Could load override config file.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1905,6 +1905,8 @@ bool config_load_override(void)
|
|||||||
/* If a core override exists, add its location to append_config_path */
|
/* If a core override exists, add its location to append_config_path */
|
||||||
if (new_conf)
|
if (new_conf)
|
||||||
{
|
{
|
||||||
|
config_file_free(new_conf);
|
||||||
|
|
||||||
if (settings->core_specific_config)
|
if (settings->core_specific_config)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Overrides: can't use overrides with with per-core configs, disabling overrides\n");
|
RARCH_LOG("Overrides: can't use overrides with with per-core configs, disabling overrides\n");
|
||||||
@ -1912,17 +1914,21 @@ bool config_load_override(void)
|
|||||||
}
|
}
|
||||||
RARCH_LOG("Overrides: core-specific overrides found at %s\n", core_path);
|
RARCH_LOG("Overrides: core-specific overrides found at %s\n", core_path);
|
||||||
strlcpy(global->path.append_config, core_path, sizeof(global->path.append_config));
|
strlcpy(global->path.append_config, core_path, sizeof(global->path.append_config));
|
||||||
|
|
||||||
should_append = true;
|
should_append = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RARCH_LOG("Overrides: no core-specific overrides found at %s\n", core_path);
|
RARCH_LOG("Overrides: no core-specific overrides found at %s\n", core_path);
|
||||||
|
|
||||||
|
|
||||||
/* Create a new config file from game_path */
|
/* Create a new config file from game_path */
|
||||||
new_conf = config_file_new(game_path);
|
new_conf = config_file_new(game_path);
|
||||||
|
|
||||||
/* If a game override exists, add it's location to append_config_path */
|
/* If a game override exists, add it's location to append_config_path */
|
||||||
if (new_conf)
|
if (new_conf)
|
||||||
{
|
{
|
||||||
|
config_file_free(new_conf);
|
||||||
|
|
||||||
RARCH_LOG("Overrides: game-specific overrides found at %s\n", game_path);
|
RARCH_LOG("Overrides: game-specific overrides found at %s\n", game_path);
|
||||||
if (should_append)
|
if (should_append)
|
||||||
{
|
{
|
||||||
@ -2077,7 +2083,7 @@ bool config_load_remap(void)
|
|||||||
if (new_conf)
|
if (new_conf)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Remaps: game-specific remap found at %s\n", game_path);
|
RARCH_LOG("Remaps: game-specific remap found at %s\n", game_path);
|
||||||
if (input_remapping_load_file(game_path))
|
if (input_remapping_load_file(new_conf, game_path))
|
||||||
{
|
{
|
||||||
rarch_main_msg_queue_push("Game remap file loaded", 1, 100, true);
|
rarch_main_msg_queue_push("Game remap file loaded", 1, 100, true);
|
||||||
return true;
|
return true;
|
||||||
@ -2097,7 +2103,7 @@ bool config_load_remap(void)
|
|||||||
if (new_conf)
|
if (new_conf)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Remaps: core-specific remap found at %s\n", core_path);
|
RARCH_LOG("Remaps: core-specific remap found at %s\n", core_path);
|
||||||
if (input_remapping_load_file(core_path))
|
if (input_remapping_load_file(new_conf, core_path))
|
||||||
{
|
{
|
||||||
rarch_main_msg_queue_push("Core remap file loaded", 1, 100, true);
|
rarch_main_msg_queue_push("Core remap file loaded", 1, 100, true);
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,16 +21,16 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* input_remapping_load_file:
|
* input_remapping_load_file:
|
||||||
* @path : Path to remapping file (absolute path).
|
* @data : Path to config file.
|
||||||
*
|
*
|
||||||
* Loads a remap file from disk to memory.
|
* Loads a remap file from disk to memory.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool input_remapping_load_file(const char *path)
|
bool input_remapping_load_file(void *data, const char *path)
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
config_file_t *conf = config_file_new(path);
|
config_file_t *conf = (config_file_t*)data;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
if (!conf || path[0] == '\0')
|
if (!conf || path[0] == '\0')
|
||||||
|
@ -26,13 +26,13 @@ extern "C" {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* input_remapping_load_file:
|
* input_remapping_load_file:
|
||||||
* @path : Path to remapping file (absolute path).
|
* @data : Path to config file.
|
||||||
*
|
*
|
||||||
* Loads a remap file from disk to memory.
|
* Loads a remap file from disk to memory.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool input_remapping_load_file(const char *path);
|
bool input_remapping_load_file(void *data, const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* input_remapping_save_file:
|
* input_remapping_save_file:
|
||||||
|
@ -691,7 +691,12 @@ static int generic_action_ok(const char *path,
|
|||||||
sizeof(global->record.config));
|
sizeof(global->record.config));
|
||||||
break;
|
break;
|
||||||
case ACTION_OK_LOAD_REMAPPING_FILE:
|
case ACTION_OK_LOAD_REMAPPING_FILE:
|
||||||
input_remapping_load_file(action_path);
|
{
|
||||||
|
config_file_t *conf = config_file_new(action_path);
|
||||||
|
|
||||||
|
if (conf)
|
||||||
|
input_remapping_load_file(conf, action_path);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_OK_LOAD_CHEAT_FILE:
|
case ACTION_OK_LOAD_CHEAT_FILE:
|
||||||
if (global->cheat)
|
if (global->cheat)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user