mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Move path variables off heap size; prevent potential memory
fragmentation
This commit is contained in:
parent
fe28f17eeb
commit
ad7db2e2b8
348
configuration.c
348
configuration.c
@ -2498,13 +2498,16 @@ void config_set_defaults(void *data)
|
||||
g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]);
|
||||
#if TARGET_OS_IPHONE
|
||||
{
|
||||
char *config_file_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
size_t config_file_path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char config_file_path[PATH_MAX_LENGTH];
|
||||
|
||||
fill_pathname_join(config_file_path, settings->paths.directory_menu_config, file_path_str(FILE_PATH_MAIN_CONFIG), config_file_path_size);
|
||||
config_file_path[0] = '\0';
|
||||
|
||||
fill_pathname_join(config_file_path,
|
||||
settings->paths.directory_menu_config,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG),
|
||||
sizeof(config_file_path));
|
||||
path_set(RARCH_PATH_CONFIG,
|
||||
config_file_path);
|
||||
free(config_file_path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -2548,15 +2551,14 @@ void config_set_defaults(void *data)
|
||||
|
||||
if (!string_is_empty(g_defaults.path_config))
|
||||
{
|
||||
char *temp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char temp_str[PATH_MAX_LENGTH];
|
||||
|
||||
temp_str[0] = '\0';
|
||||
|
||||
fill_pathname_expand_special(temp_str,
|
||||
g_defaults.path_config,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
sizeof(temp_str));
|
||||
path_set(RARCH_PATH_CONFIG, temp_str);
|
||||
free(temp_str);
|
||||
}
|
||||
|
||||
configuration_set_string(settings,
|
||||
@ -2646,37 +2648,33 @@ static bool check_menu_driver_compatibility(settings_t *settings)
|
||||
**/
|
||||
static config_file_t *open_default_config_file(void)
|
||||
{
|
||||
char application_data[PATH_MAX_LENGTH];
|
||||
char conf_path[PATH_MAX_LENGTH];
|
||||
char app_path[PATH_MAX_LENGTH];
|
||||
bool has_application_data = false;
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *application_data = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *conf_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *app_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
(void)has_application_data;
|
||||
(void)path_size;
|
||||
|
||||
application_data[0] = conf_path[0] = app_path[0] = '\0';
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
/* On UWP, the app install directory is not writable so use the writable LocalState dir instead */
|
||||
fill_pathname_home_dir(app_path, path_size);
|
||||
fill_pathname_home_dir(app_path, sizeof(app_path));
|
||||
#else
|
||||
fill_pathname_application_dir(app_path, path_size);
|
||||
fill_pathname_application_dir(app_path, sizeof(app_path));
|
||||
#endif
|
||||
fill_pathname_resolve_relative(conf_path, app_path,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
|
||||
|
||||
conf = config_file_new_from_path_to_string(conf_path);
|
||||
|
||||
if (!conf)
|
||||
{
|
||||
if (fill_pathname_application_data(application_data,
|
||||
path_size))
|
||||
sizeof(application_data)))
|
||||
{
|
||||
fill_pathname_join(conf_path, application_data,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
|
||||
conf = config_file_new_from_path_to_string(conf_path);
|
||||
}
|
||||
}
|
||||
@ -2693,7 +2691,7 @@ static config_file_t *open_default_config_file(void)
|
||||
/* Since this is a clean config file, we can
|
||||
* safely use config_save_on_exit. */
|
||||
fill_pathname_resolve_relative(conf_path, app_path,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
|
||||
config_set_bool(conf, "config_save_on_exit", true);
|
||||
saved = config_file_write(conf, conf_path, true);
|
||||
}
|
||||
@ -2710,16 +2708,16 @@ static config_file_t *open_default_config_file(void)
|
||||
}
|
||||
#elif defined(OSX)
|
||||
if (!fill_pathname_application_data(application_data,
|
||||
path_size))
|
||||
sizeof(application_data)))
|
||||
goto error;
|
||||
|
||||
/* Group config file with menu configs, remaps, etc: */
|
||||
strlcat(application_data, "/config", path_size);
|
||||
strlcat(application_data, "/config", sizeof(application_data));
|
||||
|
||||
path_mkdir(application_data);
|
||||
|
||||
fill_pathname_join(conf_path, application_data,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
|
||||
conf = config_file_new_from_path_to_string(conf_path);
|
||||
|
||||
if (!conf)
|
||||
@ -2746,12 +2744,12 @@ static config_file_t *open_default_config_file(void)
|
||||
#elif !defined(RARCH_CONSOLE)
|
||||
has_application_data =
|
||||
fill_pathname_application_data(application_data,
|
||||
path_size);
|
||||
sizeof(application_data));
|
||||
|
||||
if (has_application_data)
|
||||
{
|
||||
fill_pathname_join(conf_path, application_data,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
|
||||
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
|
||||
conf = config_file_new_from_path_to_string(conf_path);
|
||||
}
|
||||
@ -2760,7 +2758,7 @@ static config_file_t *open_default_config_file(void)
|
||||
if (!conf && getenv("HOME"))
|
||||
{
|
||||
fill_pathname_join(conf_path, getenv("HOME"),
|
||||
".retroarch.cfg", path_size);
|
||||
".retroarch.cfg", sizeof(conf_path));
|
||||
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
|
||||
conf = config_file_new_from_path_to_string(conf_path);
|
||||
}
|
||||
@ -2768,25 +2766,21 @@ static config_file_t *open_default_config_file(void)
|
||||
if (!conf && has_application_data)
|
||||
{
|
||||
bool dir_created = false;
|
||||
char *basedir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char basedir[PATH_MAX_LENGTH];
|
||||
|
||||
basedir[0] = '\0';
|
||||
|
||||
/* Try to create a new config file. */
|
||||
|
||||
strlcpy(conf_path, application_data, path_size);
|
||||
|
||||
fill_pathname_basedir(basedir, conf_path, path_size);
|
||||
|
||||
fill_pathname_join(conf_path, conf_path,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
fill_pathname_basedir(basedir, application_data, sizeof(basedir));
|
||||
fill_pathname_join(conf_path, application_data,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
|
||||
|
||||
dir_created = path_mkdir(basedir);
|
||||
free(basedir);
|
||||
|
||||
if (dir_created)
|
||||
{
|
||||
char *skeleton_conf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char skeleton_conf[PATH_MAX_LENGTH];
|
||||
bool saved = false;
|
||||
|
||||
skeleton_conf[0] = '\0';
|
||||
@ -2794,7 +2788,7 @@ static config_file_t *open_default_config_file(void)
|
||||
/* Build a retroarch.cfg path from the
|
||||
* global config directory (/etc). */
|
||||
fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(skeleton_conf));
|
||||
|
||||
conf = config_file_new_from_path_to_string(skeleton_conf);
|
||||
if (conf)
|
||||
@ -2802,8 +2796,6 @@ static config_file_t *open_default_config_file(void)
|
||||
else
|
||||
conf = config_file_new_alloc();
|
||||
|
||||
free(skeleton_conf);
|
||||
|
||||
if (conf)
|
||||
{
|
||||
/* Since this is a clean config file, we can
|
||||
@ -2815,35 +2807,27 @@ static config_file_t *open_default_config_file(void)
|
||||
if (!saved)
|
||||
{
|
||||
/* WARN here to make sure user has a good chance of seeing it. */
|
||||
RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path);
|
||||
RARCH_ERR("Failed to create new config file in: \"%s\".\n",
|
||||
conf_path);
|
||||
goto error;
|
||||
}
|
||||
|
||||
RARCH_WARN("Config: Created new config file in: \"%s\".\n", conf_path);
|
||||
RARCH_WARN("Config: Created new config file in: \"%s\".\n",
|
||||
conf_path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
(void)application_data;
|
||||
(void)conf_path;
|
||||
(void)app_path;
|
||||
|
||||
if (!conf)
|
||||
goto error;
|
||||
|
||||
path_set(RARCH_PATH_CONFIG, conf_path);
|
||||
free(application_data);
|
||||
free(conf_path);
|
||||
free(app_path);
|
||||
|
||||
return conf;
|
||||
|
||||
error:
|
||||
if (conf)
|
||||
config_file_free(conf);
|
||||
free(application_data);
|
||||
free(conf_path);
|
||||
free(app_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2892,8 +2876,7 @@ static bool config_load_file(global_t *global,
|
||||
const char *path, settings_t *settings)
|
||||
{
|
||||
unsigned i;
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char tmp_str[PATH_MAX_LENGTH];
|
||||
bool ret = false;
|
||||
unsigned tmp_uint = 0;
|
||||
bool tmp_bool = false;
|
||||
@ -2931,13 +2914,13 @@ static bool config_load_file(global_t *global,
|
||||
{
|
||||
/* Don't destroy append_config_path, store in temporary
|
||||
* variable. */
|
||||
char *tmp_append_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char tmp_append_path[PATH_MAX_LENGTH];
|
||||
const char *extra_path = NULL;
|
||||
|
||||
tmp_append_path[0] = '\0';
|
||||
|
||||
strlcpy(tmp_append_path, path_get(RARCH_PATH_CONFIG_APPEND),
|
||||
path_size);
|
||||
sizeof(tmp_append_path));
|
||||
extra_path = strtok_r(tmp_append_path, "|", &save);
|
||||
|
||||
while (extra_path)
|
||||
@ -2950,8 +2933,6 @@ static bool config_load_file(global_t *global,
|
||||
RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path);
|
||||
extra_path = strtok_r(NULL, "|", &save);
|
||||
}
|
||||
|
||||
free(tmp_append_path);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -3099,16 +3080,16 @@ static bool config_load_file(global_t *global,
|
||||
{
|
||||
if (!path_settings[i].handle)
|
||||
continue;
|
||||
if (config_get_path(conf, path_settings[i].ident, tmp_str, path_size))
|
||||
if (config_get_path(conf, path_settings[i].ident, tmp_str, sizeof(tmp_str)))
|
||||
strlcpy(path_settings[i].ptr, tmp_str, PATH_MAX_LENGTH);
|
||||
}
|
||||
|
||||
if (config_get_path(conf, "libretro_directory", tmp_str, path_size))
|
||||
if (config_get_path(conf, "libretro_directory", tmp_str, sizeof(tmp_str)))
|
||||
configuration_set_string(settings,
|
||||
settings->paths.directory_libretro, tmp_str);
|
||||
|
||||
#ifndef HAVE_DYNAMIC
|
||||
if (config_get_path(conf, "libretro_path", tmp_str, path_size))
|
||||
if (config_get_path(conf, "libretro_path", tmp_str, sizeof(tmp_str)))
|
||||
path_set(RARCH_PATH_CORE, tmp_str);
|
||||
#endif
|
||||
|
||||
@ -3318,7 +3299,7 @@ static bool config_load_file(global_t *global,
|
||||
#endif
|
||||
|
||||
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL) &&
|
||||
config_get_path(conf, "savefile_directory", tmp_str, path_size))
|
||||
config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str)))
|
||||
{
|
||||
if (string_is_equal(tmp_str, "default"))
|
||||
dir_set(RARCH_DIR_SAVEFILE, g_defaults.dirs[DEFAULT_DIR_SRAM]);
|
||||
@ -3342,7 +3323,7 @@ static bool config_load_file(global_t *global,
|
||||
}
|
||||
|
||||
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL) &&
|
||||
config_get_path(conf, "savestate_directory", tmp_str, path_size))
|
||||
config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str)))
|
||||
{
|
||||
if (string_is_equal(tmp_str, "default"))
|
||||
dir_set(RARCH_DIR_SAVESTATE, g_defaults.dirs[DEFAULT_DIR_SAVESTATE]);
|
||||
@ -3417,7 +3398,6 @@ end:
|
||||
free(path_settings);
|
||||
if (size_settings)
|
||||
free(size_settings);
|
||||
free(tmp_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3442,12 +3422,12 @@ end:
|
||||
*/
|
||||
bool config_load_override(void *data)
|
||||
{
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *buf = NULL;
|
||||
char *core_path = NULL;
|
||||
char *game_path = NULL;
|
||||
char *content_path = NULL;
|
||||
char *config_directory = NULL;
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
char core_path[PATH_MAX_LENGTH];
|
||||
char game_path[PATH_MAX_LENGTH];
|
||||
char content_path[PATH_MAX_LENGTH];
|
||||
char content_dir_name[PATH_MAX_LENGTH];
|
||||
char config_directory[PATH_MAX_LENGTH];
|
||||
bool should_append = false;
|
||||
rarch_system_info_t *system = (rarch_system_info_t*)data;
|
||||
const char *core_name = system ?
|
||||
@ -3455,7 +3435,6 @@ bool config_load_override(void *data)
|
||||
const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME);
|
||||
const char *game_name = path_basename(rarch_path_basename);
|
||||
settings_t *settings = config_get_ptr();
|
||||
char content_dir_name[PATH_MAX_LENGTH];
|
||||
|
||||
if (!string_is_empty(rarch_path_basename))
|
||||
fill_pathname_parent_dir_name(content_dir_name,
|
||||
@ -3464,41 +3443,30 @@ bool config_load_override(void *data)
|
||||
if (string_is_empty(core_name) || string_is_empty(game_name))
|
||||
return false;
|
||||
|
||||
game_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
core_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
content_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
buf = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
config_directory = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
config_directory[0] = core_path[0] = game_path[0] = '\0';
|
||||
config_directory[0] = core_path[0] = game_path[0] = buf[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(config_directory, path_size,
|
||||
fill_pathname_application_special(config_directory, sizeof(config_directory),
|
||||
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
|
||||
|
||||
/* Concatenate strings into full paths for core_path, game_path, content_path */
|
||||
/* Concatenate strings into full paths for core_path, game_path,
|
||||
* content_path */
|
||||
fill_pathname_join_special_ext(game_path,
|
||||
config_directory, core_name,
|
||||
game_name,
|
||||
".cfg",
|
||||
path_size);
|
||||
sizeof(game_path));
|
||||
|
||||
fill_pathname_join_special_ext(content_path,
|
||||
config_directory, core_name,
|
||||
content_dir_name,
|
||||
".cfg",
|
||||
path_size);
|
||||
sizeof(content_path));
|
||||
|
||||
fill_pathname_join_special_ext(core_path,
|
||||
config_directory, core_name,
|
||||
core_name,
|
||||
".cfg",
|
||||
path_size);
|
||||
|
||||
free(config_directory);
|
||||
sizeof(core_path));
|
||||
|
||||
/* per-core overrides */
|
||||
/* Create a new config file from core_path */
|
||||
@ -3519,7 +3487,7 @@ bool config_load_override(void *data)
|
||||
/* Create a new config file from content_path */
|
||||
if (config_file_exists(content_path))
|
||||
{
|
||||
char *temp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char temp_path[PATH_MAX_LENGTH];
|
||||
|
||||
temp_path[0] = '\0';
|
||||
|
||||
@ -3529,17 +3497,15 @@ bool config_load_override(void *data)
|
||||
if (should_append)
|
||||
{
|
||||
RARCH_LOG("[Overrides]: Content dir-specific overrides stacking on top of previous overrides.\n");
|
||||
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), path_size);
|
||||
strlcat(temp_path, "|", path_size);
|
||||
strlcat(temp_path, content_path, path_size);
|
||||
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), sizeof(temp_path));
|
||||
strlcat(temp_path, "|", sizeof(temp_path));
|
||||
strlcat(temp_path, content_path, sizeof(temp_path));
|
||||
}
|
||||
else
|
||||
strlcpy(temp_path, content_path, path_size);
|
||||
strlcpy(temp_path, content_path, sizeof(temp_path));
|
||||
|
||||
path_set(RARCH_PATH_CONFIG_APPEND, temp_path);
|
||||
|
||||
free(temp_path);
|
||||
|
||||
should_append = true;
|
||||
}
|
||||
else
|
||||
@ -3550,7 +3516,7 @@ bool config_load_override(void *data)
|
||||
/* Create a new config file from game_path */
|
||||
if (config_file_exists(game_path))
|
||||
{
|
||||
char *temp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char temp_path[PATH_MAX_LENGTH];
|
||||
|
||||
temp_path[0] = '\0';
|
||||
|
||||
@ -3560,17 +3526,15 @@ bool config_load_override(void *data)
|
||||
if (should_append)
|
||||
{
|
||||
RARCH_LOG("[Overrides]: game-specific overrides stacking on top of previous overrides\n");
|
||||
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), path_size);
|
||||
strlcat(temp_path, "|", path_size);
|
||||
strlcat(temp_path, game_path, path_size);
|
||||
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), sizeof(temp_path));
|
||||
strlcat(temp_path, "|", sizeof(temp_path));
|
||||
strlcat(temp_path, game_path, sizeof(temp_path));
|
||||
}
|
||||
else
|
||||
strlcpy(temp_path, game_path, path_size);
|
||||
strlcpy(temp_path, game_path, sizeof(temp_path));
|
||||
|
||||
path_set(RARCH_PATH_CONFIG_APPEND, temp_path);
|
||||
|
||||
free(temp_path);
|
||||
|
||||
should_append = true;
|
||||
}
|
||||
else
|
||||
@ -3578,15 +3542,13 @@ bool config_load_override(void *data)
|
||||
game_path);
|
||||
|
||||
if (!should_append)
|
||||
goto error;
|
||||
return false;
|
||||
|
||||
/* Re-load the configuration with any overrides
|
||||
* that might have been found */
|
||||
buf[0] = '\0';
|
||||
|
||||
/* Store the libretro_path we're using since it will be
|
||||
* overwritten by the override when reloading. */
|
||||
strlcpy(buf, path_get(RARCH_PATH_CORE), path_size);
|
||||
strlcpy(buf, path_get(RARCH_PATH_CORE), sizeof(buf));
|
||||
|
||||
/* Toggle has_save_path to false so it resets */
|
||||
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
|
||||
@ -3594,7 +3556,7 @@ bool config_load_override(void *data)
|
||||
|
||||
if (!config_load_file(global_get_ptr(),
|
||||
path_get(RARCH_PATH_CONFIG), settings))
|
||||
goto error;
|
||||
return false;
|
||||
|
||||
/* Restore the libretro_path we're using
|
||||
* since it will be overwritten by the override when reloading. */
|
||||
@ -3610,18 +3572,7 @@ bool config_load_override(void *data)
|
||||
|
||||
path_clear(RARCH_PATH_CONFIG_APPEND);
|
||||
|
||||
free(buf);
|
||||
free(core_path);
|
||||
free(content_path);
|
||||
free(game_path);
|
||||
return true;
|
||||
|
||||
error:
|
||||
free(buf);
|
||||
free(core_path);
|
||||
free(content_path);
|
||||
free(game_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3669,12 +3620,16 @@ bool config_unload_override(void)
|
||||
bool config_load_remap(const char *directory_input_remapping,
|
||||
void *data)
|
||||
{
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char content_dir_name[PATH_MAX_LENGTH];
|
||||
/* path to the directory containing retroarch.cfg (prefix) */
|
||||
char remap_directory[PATH_MAX_LENGTH];
|
||||
/* final path for core-specific configuration (prefix+suffix) */
|
||||
char core_path[PATH_MAX_LENGTH];
|
||||
/* final path for game-specific configuration (prefix+suffix) */
|
||||
char game_path[PATH_MAX_LENGTH];
|
||||
/* final path for content-dir-specific configuration (prefix+suffix) */
|
||||
char content_path[PATH_MAX_LENGTH];
|
||||
config_file_t *new_conf = NULL;
|
||||
char *remap_directory = NULL;
|
||||
char *core_path = NULL;
|
||||
char *game_path = NULL;
|
||||
char *content_path = NULL;
|
||||
rarch_system_info_t *system = (rarch_system_info_t*)data;
|
||||
const char *core_name = system ? system->info.library_name : NULL;
|
||||
const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME);
|
||||
@ -3682,7 +3637,6 @@ bool config_load_remap(const char *directory_input_remapping,
|
||||
enum msg_hash_enums msg_remap_loaded = MSG_GAME_REMAP_FILE_LOADED;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool notification_show_remap_load = settings->bools.notification_show_remap_load;
|
||||
char content_dir_name[PATH_MAX_LENGTH];
|
||||
|
||||
if (string_is_empty(core_name) || string_is_empty(game_name))
|
||||
return false;
|
||||
@ -3696,21 +3650,10 @@ bool config_load_remap(const char *directory_input_remapping,
|
||||
fill_pathname_parent_dir_name(content_dir_name,
|
||||
rarch_path_basename, sizeof(content_dir_name));
|
||||
|
||||
/* path to the directory containing retroarch.cfg (prefix) */
|
||||
remap_directory = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
/* final path for core-specific configuration (prefix+suffix) */
|
||||
core_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
/* final path for game-specific configuration (prefix+suffix) */
|
||||
game_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
/* final path for content-dir-specific configuration (prefix+suffix) */
|
||||
content_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
remap_directory[0] = core_path[0] = game_path[0] = '\0';
|
||||
|
||||
strlcpy(remap_directory, directory_input_remapping, path_size);
|
||||
strlcpy(remap_directory,
|
||||
directory_input_remapping, sizeof(remap_directory));
|
||||
RARCH_LOG("[Remaps]: remap directory: %s\n", remap_directory);
|
||||
|
||||
/* Concatenate strings into full paths for core_path, game_path */
|
||||
@ -3718,19 +3661,19 @@ bool config_load_remap(const char *directory_input_remapping,
|
||||
remap_directory, core_name,
|
||||
core_name,
|
||||
".rmp",
|
||||
path_size);
|
||||
sizeof(core_path));
|
||||
|
||||
fill_pathname_join_special_ext(content_path,
|
||||
remap_directory, core_name,
|
||||
content_dir_name,
|
||||
".rmp",
|
||||
path_size);
|
||||
sizeof(content_path));
|
||||
|
||||
fill_pathname_join_special_ext(game_path,
|
||||
remap_directory, core_name,
|
||||
game_name,
|
||||
".rmp",
|
||||
path_size);
|
||||
sizeof(game_path));
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
input_remapping_set_defaults(false);
|
||||
@ -3775,10 +3718,6 @@ bool config_load_remap(const char *directory_input_remapping,
|
||||
|
||||
new_conf = NULL;
|
||||
|
||||
free(content_path);
|
||||
free(remap_directory);
|
||||
free(core_path);
|
||||
free(game_path);
|
||||
return false;
|
||||
|
||||
success:
|
||||
@ -3786,11 +3725,6 @@ success:
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(msg_remap_loaded), 1, 100, false,
|
||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
free(content_path);
|
||||
free(remap_directory);
|
||||
free(core_path);
|
||||
free(game_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3846,7 +3780,8 @@ static void video_driver_save_settings(config_file_t *conf)
|
||||
* @user : Controller number to save
|
||||
* Writes a controller autoconf file to disk.
|
||||
**/
|
||||
bool config_save_autoconf_profile(const char *device_name, unsigned user)
|
||||
bool config_save_autoconf_profile(const
|
||||
char *device_name, unsigned user)
|
||||
{
|
||||
static const char* invalid_filename_chars[] = {
|
||||
/* https://support.microsoft.com/en-us/help/905231/information-about-the-characters-that-you-cannot-use-in-site-names--fo */
|
||||
@ -3854,8 +3789,9 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
|
||||
NULL
|
||||
};
|
||||
size_t i;
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
char autoconf_file[PATH_MAX_LENGTH];
|
||||
config_file_t *conf = NULL;
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
int32_t pid_user = 0;
|
||||
int32_t vid_user = 0;
|
||||
bool ret = false;
|
||||
@ -3864,16 +3800,9 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
|
||||
const char *joypad_driver_fallback = settings->arrays.input_joypad_driver;
|
||||
const char *joypad_driver = NULL;
|
||||
char *sanitised_name = NULL;
|
||||
char *buf = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *autoconf_file = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
if (!buf || !autoconf_file)
|
||||
goto end;
|
||||
|
||||
buf[0] = '\0';
|
||||
autoconf_file[0] = '\0';
|
||||
buf[0] = '\0';
|
||||
autoconf_file[0] = '\0';
|
||||
|
||||
if (string_is_empty(device_name))
|
||||
goto end;
|
||||
@ -3892,18 +3821,16 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Remove invalid filename characters from
|
||||
* input device name */
|
||||
sanitised_name = strdup(device_name);
|
||||
|
||||
if (string_is_empty(sanitised_name))
|
||||
goto end;
|
||||
|
||||
/* Remove invalid filename characters from
|
||||
* input device name */
|
||||
for (i = 0; invalid_filename_chars[i]; i++)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
char *tmp = strstr(sanitised_name, invalid_filename_chars[i]);
|
||||
char *tmp = strstr(sanitised_name,
|
||||
invalid_filename_chars[i]);
|
||||
|
||||
if (tmp)
|
||||
*tmp = '_';
|
||||
@ -3912,31 +3839,26 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate autconfig file path */
|
||||
fill_pathname_join(buf, autoconf_dir, joypad_driver, path_size);
|
||||
/* Generate autoconfig file path */
|
||||
fill_pathname_join(buf, autoconf_dir, joypad_driver, sizeof(buf));
|
||||
|
||||
if (path_is_directory(buf))
|
||||
{
|
||||
char *buf_new = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
if (!buf_new)
|
||||
goto end;
|
||||
char buf_new[PATH_MAX_LENGTH];
|
||||
|
||||
buf_new[0] = '\0';
|
||||
|
||||
fill_pathname_join(buf_new, buf,
|
||||
sanitised_name, path_size);
|
||||
sanitised_name, sizeof(buf_new));
|
||||
fill_pathname_noext(autoconf_file,
|
||||
buf_new, ".cfg", path_size);
|
||||
|
||||
free(buf_new);
|
||||
buf_new, ".cfg", sizeof(autoconf_file));
|
||||
}
|
||||
else
|
||||
{
|
||||
fill_pathname_join(buf, autoconf_dir,
|
||||
sanitised_name, path_size);
|
||||
sanitised_name, sizeof(buf));
|
||||
fill_pathname_noext(autoconf_file,
|
||||
buf, ".cfg", path_size);
|
||||
buf, ".cfg", sizeof(autoconf_file));
|
||||
}
|
||||
|
||||
/* Open config file */
|
||||
@ -3982,12 +3904,6 @@ end:
|
||||
if (sanitised_name)
|
||||
free(sanitised_name);
|
||||
|
||||
if (buf)
|
||||
free(buf);
|
||||
|
||||
if (autoconf_file)
|
||||
free(autoconf_file);
|
||||
|
||||
if (conf)
|
||||
config_file_free(conf);
|
||||
|
||||
@ -4225,7 +4141,6 @@ bool config_save_file(const char *path)
|
||||
**/
|
||||
bool config_save_overrides(enum override_type type, void *data)
|
||||
{
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
int tmp_i = 0;
|
||||
unsigned i = 0;
|
||||
bool ret = false;
|
||||
@ -4245,11 +4160,11 @@ bool config_save_overrides(enum override_type type, void *data)
|
||||
struct config_array_setting *array_overrides= NULL;
|
||||
struct config_path_setting *path_settings = NULL;
|
||||
struct config_path_setting *path_overrides = NULL;
|
||||
char *config_directory = NULL;
|
||||
char *override_directory = NULL;
|
||||
char *core_path = NULL;
|
||||
char *game_path = NULL;
|
||||
char *content_path = NULL;
|
||||
char config_directory[PATH_MAX_LENGTH];
|
||||
char override_directory[PATH_MAX_LENGTH];
|
||||
char core_path[PATH_MAX_LENGTH];
|
||||
char game_path[PATH_MAX_LENGTH];
|
||||
char content_path[PATH_MAX_LENGTH];
|
||||
settings_t *overrides = config_get_ptr();
|
||||
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
|
||||
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
|
||||
@ -4270,20 +4185,16 @@ bool config_save_overrides(enum override_type type, void *data)
|
||||
if (string_is_empty(core_name) || string_is_empty(game_name))
|
||||
return false;
|
||||
|
||||
settings = (settings_t*)calloc(1, sizeof(settings_t));
|
||||
config_directory = (char*)malloc(PATH_MAX_LENGTH);
|
||||
override_directory = (char*)malloc(PATH_MAX_LENGTH);
|
||||
core_path = (char*)malloc(PATH_MAX_LENGTH);
|
||||
game_path = (char*)malloc(PATH_MAX_LENGTH);
|
||||
content_path = (char*)malloc(PATH_MAX_LENGTH);
|
||||
settings = (settings_t*)calloc(1, sizeof(settings_t));
|
||||
|
||||
config_directory[0] = override_directory[0] = core_path[0] = game_path[0] = '\0';
|
||||
config_directory[0] = override_directory[0] = core_path[0] =
|
||||
game_path[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(config_directory, path_size,
|
||||
fill_pathname_application_special(config_directory, sizeof(config_directory),
|
||||
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
|
||||
|
||||
fill_pathname_join(override_directory, config_directory, core_name,
|
||||
path_size);
|
||||
sizeof(override_directory));
|
||||
|
||||
if (!path_is_directory(override_directory))
|
||||
path_mkdir(override_directory);
|
||||
@ -4293,19 +4204,19 @@ bool config_save_overrides(enum override_type type, void *data)
|
||||
config_directory, core_name,
|
||||
game_name,
|
||||
".cfg",
|
||||
path_size);
|
||||
sizeof(game_path));
|
||||
|
||||
fill_pathname_join_special_ext(content_path,
|
||||
config_directory, core_name,
|
||||
content_dir_name,
|
||||
".cfg",
|
||||
path_size);
|
||||
sizeof(content_path));
|
||||
|
||||
fill_pathname_join_special_ext(core_path,
|
||||
config_directory, core_name,
|
||||
core_name,
|
||||
".cfg",
|
||||
path_size);
|
||||
sizeof(core_path));
|
||||
|
||||
if (!conf)
|
||||
conf = config_file_new_alloc();
|
||||
@ -4464,11 +4375,6 @@ bool config_save_overrides(enum override_type type, void *data)
|
||||
if (size_overrides)
|
||||
free(size_overrides);
|
||||
free(settings);
|
||||
free(config_directory);
|
||||
free(override_directory);
|
||||
free(core_path);
|
||||
free(game_path);
|
||||
free(content_path);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -4621,9 +4527,8 @@ bool input_remapping_save_file(const char *path)
|
||||
{
|
||||
bool ret;
|
||||
unsigned i, j, k;
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *remap_file = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
char remap_file[PATH_MAX_LENGTH];
|
||||
config_file_t *conf = NULL;
|
||||
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -4631,18 +4536,13 @@ bool input_remapping_save_file(const char *path)
|
||||
|
||||
buf[0] = remap_file[0] = '\0';
|
||||
|
||||
fill_pathname_join(buf, dir_input_remapping, path, path_size);
|
||||
fill_pathname_noext(remap_file, buf, ".rmp", path_size);
|
||||
|
||||
free(buf);
|
||||
fill_pathname_join(buf, dir_input_remapping, path, sizeof(buf));
|
||||
fill_pathname_noext(remap_file, buf, ".rmp", sizeof(remap_file));
|
||||
|
||||
if (!(conf = config_file_new_from_path_to_string(remap_file)))
|
||||
{
|
||||
if (!(conf = config_file_new_alloc()))
|
||||
{
|
||||
free(remap_file);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < max_users; i++)
|
||||
@ -4715,26 +4615,20 @@ bool input_remapping_save_file(const char *path)
|
||||
ret = config_file_write(conf, remap_file, true);
|
||||
config_file_free(conf);
|
||||
|
||||
free(remap_file);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool input_remapping_remove_file(const char *path,
|
||||
const char *dir_input_remapping)
|
||||
{
|
||||
bool ret = false;
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *remap_file = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
char remap_file[PATH_MAX_LENGTH];
|
||||
buf[0] = remap_file[0] = '\0';
|
||||
|
||||
fill_pathname_join(buf, dir_input_remapping, path, path_size);
|
||||
fill_pathname_noext(remap_file, buf, ".rmp", path_size);
|
||||
fill_pathname_join(buf, dir_input_remapping, path, sizeof(buf));
|
||||
fill_pathname_noext(remap_file, buf, ".rmp", sizeof(remap_file));
|
||||
|
||||
ret = filestream_delete(remap_file) == 0 ? true : false;
|
||||
free(buf);
|
||||
free(remap_file);
|
||||
return ret;
|
||||
return filestream_delete(remap_file) == 0 ? true : false;
|
||||
}
|
||||
|
||||
void input_remapping_set_defaults(bool deinit)
|
||||
|
39
core_info.c
39
core_info.c
@ -195,21 +195,18 @@ static config_file_t *core_info_list_iterate(
|
||||
const char *current_path,
|
||||
const char *path_basedir)
|
||||
{
|
||||
size_t info_path_base_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *info_path_base = NULL;
|
||||
char *info_path = NULL;
|
||||
config_file_t *conf = NULL;
|
||||
char info_path[PATH_MAX_LENGTH];
|
||||
char info_path_base[PATH_MAX_LENGTH];
|
||||
|
||||
if (!current_path)
|
||||
return NULL;
|
||||
|
||||
info_path_base = (char*)malloc(info_path_base_size);
|
||||
|
||||
info_path_base[0] = '\0';
|
||||
info_path [0] = '\0';
|
||||
info_path_base[0] = '\0';
|
||||
|
||||
fill_pathname_base_noext(info_path_base,
|
||||
current_path,
|
||||
info_path_base_size);
|
||||
sizeof(info_path_base));
|
||||
|
||||
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(HW_WUP))
|
||||
{
|
||||
@ -219,20 +216,15 @@ static config_file_t *core_info_list_iterate(
|
||||
}
|
||||
#endif
|
||||
|
||||
strlcat(info_path_base, ".info", info_path_base_size);
|
||||
strlcat(info_path_base, ".info", sizeof(info_path_base));
|
||||
|
||||
info_path = (char*)malloc(info_path_base_size);
|
||||
fill_pathname_join(info_path,
|
||||
path_basedir,
|
||||
info_path_base, info_path_base_size);
|
||||
free(info_path_base);
|
||||
info_path_base = NULL;
|
||||
info_path_base, sizeof(info_path_base));
|
||||
|
||||
if (path_is_valid(info_path))
|
||||
conf = config_file_new_from_path_to_string(info_path);
|
||||
free(info_path);
|
||||
|
||||
return conf;
|
||||
return config_file_new_from_path_to_string(info_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Returned path must be free()'d */
|
||||
@ -633,9 +625,8 @@ static bool core_info_list_update_missing_firmware_internal(
|
||||
bool *set_missing_bios)
|
||||
{
|
||||
size_t i;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
core_info_t *info = NULL;
|
||||
char *path = NULL;
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
|
||||
if (!core_info_list || !core)
|
||||
return false;
|
||||
@ -645,11 +636,6 @@ static bool core_info_list_update_missing_firmware_internal(
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
path = (char*)malloc(path_size);
|
||||
|
||||
if (!path)
|
||||
return false;
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
for (i = 0; i < info->firmware_count; i++)
|
||||
@ -658,13 +644,12 @@ static bool core_info_list_update_missing_firmware_internal(
|
||||
continue;
|
||||
|
||||
fill_pathname_join(path, systemdir,
|
||||
info->firmware[i].path, path_size);
|
||||
info->firmware[i].path, sizeof(path));
|
||||
info->firmware[i].missing = !path_is_valid(path);
|
||||
if (info->firmware[i].missing && !info->firmware[i].optional)
|
||||
*set_missing_bios = true;
|
||||
}
|
||||
|
||||
free(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1142,7 +1127,7 @@ core_updater_info_t *core_info_get_core_updater_info(const char *path)
|
||||
return NULL;
|
||||
|
||||
/* Create info struct */
|
||||
info = (core_updater_info_t*)malloc(sizeof(*info));
|
||||
info = (core_updater_info_t*)malloc(sizeof(*info));
|
||||
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
@ -169,36 +169,24 @@ void fill_pathname_application_special(char *s,
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG:
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
char *s1 = (char*)malloc(
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
s1[0] = '\0';
|
||||
fill_pathname_join(s1, dir_assets, "pkg", PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcpy(s, s1, len);
|
||||
free(s1);
|
||||
fill_pathname_join(s, dir_assets, "pkg", len);
|
||||
}
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS:
|
||||
#ifdef HAVE_XMB
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *s2 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s2[PATH_MAX_LENGTH];
|
||||
|
||||
s1[0] = '\0';
|
||||
s2[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB);
|
||||
fill_pathname_join(s2, s1, "png",
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
fill_pathname_slash(s2,
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
fill_pathname_join(s2, s1, "png", sizeof(s2));
|
||||
fill_pathname_slash(s2, sizeof(s2));
|
||||
strlcpy(s, s2, len);
|
||||
free(s1);
|
||||
free(s2);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -212,15 +200,13 @@ void fill_pathname_application_special(char *s,
|
||||
strlcpy(s, path_menu_wallpaper, len);
|
||||
else
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
|
||||
s1[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
fill_pathname_join(s, s1, "bg.png", len);
|
||||
free(s1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -296,18 +282,10 @@ void fill_pathname_application_special(char *s,
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE:
|
||||
#ifdef HAVE_OZONE
|
||||
{
|
||||
char *s1 = (char*)malloc(
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
|
||||
s1[0] = '\0';
|
||||
|
||||
fill_pathname_join(s1, dir_assets, "ozone",
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
strlcpy(s, s1, len);
|
||||
free(s1);
|
||||
fill_pathname_join(s, dir_assets, "ozone",
|
||||
len);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -338,19 +316,15 @@ void fill_pathname_application_special(char *s,
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB:
|
||||
#ifdef HAVE_XMB
|
||||
{
|
||||
char *s1 = (char*)malloc(
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
|
||||
s1[0] = '\0';
|
||||
|
||||
fill_pathname_join(s1, dir_assets, "xmb",
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
fill_pathname_join(s1, dir_assets, "xmb", sizeof(s1));
|
||||
fill_pathname_join(s,
|
||||
s1, xmb_theme_ident(), len);
|
||||
free(s1);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -366,57 +340,40 @@ void fill_pathname_application_special(char *s,
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_ICONS:
|
||||
#ifdef HAVE_MATERIALUI
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
s1[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI);
|
||||
strlcpy(s, s1, len);
|
||||
|
||||
free(s1);
|
||||
}
|
||||
fill_pathname_application_special(s, len,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI);
|
||||
#endif
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT:
|
||||
#ifdef HAVE_MATERIALUI
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
s1[0] = '\0';
|
||||
|
||||
switch (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE))
|
||||
{
|
||||
case RETRO_LANGUAGE_ARABIC:
|
||||
case RETRO_LANGUAGE_PERSIAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(s, s1, "fallback-font.ttf", len);
|
||||
break;
|
||||
case RETRO_LANGUAGE_CHINESE_SIMPLIFIED:
|
||||
case RETRO_LANGUAGE_CHINESE_TRADITIONAL:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(s, s1, "chinese-fallback-font.ttf", len);
|
||||
break;
|
||||
case RETRO_LANGUAGE_KOREAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(s, s1, "korean-fallback-font.ttf", len);
|
||||
break;
|
||||
default:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI);
|
||||
fill_pathname_join(s, s1, "font.ttf", len);
|
||||
}
|
||||
|
||||
free(s1);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -430,90 +387,70 @@ void fill_pathname_application_special(char *s,
|
||||
strlcpy(s, path_menu_xmb_font, len);
|
||||
else
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
s1[0] = '\0';
|
||||
|
||||
switch (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE))
|
||||
{
|
||||
case RETRO_LANGUAGE_ARABIC:
|
||||
case RETRO_LANGUAGE_PERSIAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(s, s1, "fallback-font.ttf", len);
|
||||
break;
|
||||
case RETRO_LANGUAGE_CHINESE_SIMPLIFIED:
|
||||
case RETRO_LANGUAGE_CHINESE_TRADITIONAL:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(s, s1, "chinese-fallback-font.ttf", len);
|
||||
break;
|
||||
case RETRO_LANGUAGE_KOREAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(s, s1, "korean-fallback-font.ttf", len);
|
||||
break;
|
||||
default:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB);
|
||||
fill_pathname_join(s, s1, "font.ttf", len);
|
||||
}
|
||||
free(s1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS:
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *s2 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s2[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_thumbnails = settings->paths.directory_thumbnails;
|
||||
|
||||
s1[0] = '\0';
|
||||
s2[0] = '\0';
|
||||
|
||||
fill_pathname_join(s1, dir_thumbnails, "discord", len);
|
||||
fill_pathname_join(s1, dir_thumbnails, "discord", sizeof(s1));
|
||||
fill_pathname_join(s2,
|
||||
s1, "avatars",
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
fill_pathname_slash(s2,
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
s1, "avatars", sizeof(s2));
|
||||
fill_pathname_slash(s2, sizeof(s2));
|
||||
strlcpy(s, s2, len);
|
||||
free(s1);
|
||||
free(s2);
|
||||
}
|
||||
break;
|
||||
|
||||
case APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES:
|
||||
{
|
||||
char *s1 = (char*)malloc(
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
char *s2 = (char*)malloc(
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s2[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_thumbnails = settings->paths.directory_thumbnails;
|
||||
|
||||
s1[0] = '\0';
|
||||
s2[0] = '\0';
|
||||
s1[0] = '\0';
|
||||
s2[0] = '\0';
|
||||
|
||||
fill_pathname_join(s1, dir_thumbnails, "cheevos", len);
|
||||
fill_pathname_join(s2,
|
||||
s1, "badges",
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
fill_pathname_slash(s2,
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
s1, "badges", sizeof(s2));
|
||||
fill_pathname_slash(s2, sizeof(s2));
|
||||
strlcpy(s, s2, len);
|
||||
free(s1);
|
||||
free(s2);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -417,7 +417,7 @@ end:
|
||||
static int general_push(menu_displaylist_info_t *info,
|
||||
unsigned id, enum menu_displaylist_ctl_state state)
|
||||
{
|
||||
char *newstring2 = NULL;
|
||||
char newstring2[PATH_MAX_LENGTH];
|
||||
core_info_list_t *list = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
@ -473,8 +473,6 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
break;
|
||||
}
|
||||
|
||||
newstring2 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
newstring2[0] = '\0';
|
||||
|
||||
switch (id)
|
||||
@ -484,11 +482,9 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
struct retro_system_info *system =
|
||||
runloop_get_libretro_system_info();
|
||||
if (system)
|
||||
{
|
||||
if (!string_is_empty(system->valid_extensions))
|
||||
strlcpy(newstring2, system->valid_extensions,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
}
|
||||
sizeof(newstring2));
|
||||
}
|
||||
break;
|
||||
case PUSH_DEFAULT:
|
||||
@ -496,9 +492,8 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
bool new_exts_allocated = false;
|
||||
char *new_exts = NULL;
|
||||
|
||||
if (menu_setting_get_browser_selection_type(info->setting) == ST_DIR)
|
||||
{
|
||||
}
|
||||
if (menu_setting_get_browser_selection_type(info->setting)
|
||||
== ST_DIR) { }
|
||||
else
|
||||
{
|
||||
struct retro_system_info *system =
|
||||
@ -515,19 +510,15 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
|
||||
if (!string_is_empty(new_exts))
|
||||
{
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
struct string_list *str_list3 = string_split(new_exts, "|");
|
||||
|
||||
#ifdef HAVE_IBXM
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
attr.i = 0;
|
||||
string_list_append(str_list3, "s3m", attr);
|
||||
string_list_append(str_list3, "mod", attr);
|
||||
string_list_append(str_list3, "xm", attr);
|
||||
}
|
||||
union string_list_elem_attr attr;
|
||||
attr.i = 0;
|
||||
string_list_append(str_list3, "s3m", attr);
|
||||
string_list_append(str_list3, "mod", attr);
|
||||
string_list_append(str_list3, "xm", attr);
|
||||
#endif
|
||||
string_list_join_concat(newstring2, path_size,
|
||||
string_list_join_concat(newstring2, sizeof(newstring2),
|
||||
str_list3, "|");
|
||||
string_list_free(str_list3);
|
||||
|
||||
@ -546,8 +537,7 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
case PUSH_DETECT_CORE_LIST:
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *newstring = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char newstring[PATH_MAX_LENGTH];
|
||||
struct string_list *str_list2 = string_list_new();
|
||||
struct retro_system_info *system = runloop_get_libretro_system_info();
|
||||
|
||||
@ -593,7 +583,7 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
}
|
||||
}
|
||||
|
||||
string_list_join_concat(newstring, path_size,
|
||||
string_list_join_concat(newstring, sizeof(newstring),
|
||||
str_list2, "|");
|
||||
|
||||
{
|
||||
@ -608,11 +598,10 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
string_list_append(str_list3, "xm", attr);
|
||||
}
|
||||
#endif
|
||||
string_list_join_concat(newstring2, path_size,
|
||||
string_list_join_concat(newstring2, sizeof(newstring2),
|
||||
str_list3, "|");
|
||||
string_list_free(str_list3);
|
||||
}
|
||||
free(newstring);
|
||||
string_list_free(str_list2);
|
||||
}
|
||||
break;
|
||||
@ -632,18 +621,17 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
#elif defined(HAVE_MPV)
|
||||
libretro_mpv_retro_get_system_info(&sysinfo);
|
||||
#endif
|
||||
strlcat(newstring2, "|", PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(newstring2, sysinfo.valid_extensions,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(newstring2, "|", sizeof(newstring2));
|
||||
strlcat(newstring2, sysinfo.valid_extensions, sizeof(newstring2));
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_IMAGEVIEWER
|
||||
if (multimedia_builtin_imageviewer_enable)
|
||||
{
|
||||
libretro_imageviewer_retro_get_system_info(&sysinfo);
|
||||
strlcat(newstring2, "|", PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(newstring2, "|", sizeof(newstring2));
|
||||
strlcat(newstring2, sysinfo.valid_extensions,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
sizeof(newstring2));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -654,7 +642,6 @@ static int general_push(menu_displaylist_info_t *info,
|
||||
free(info->exts);
|
||||
info->exts = strdup(newstring2);
|
||||
}
|
||||
free(newstring2);
|
||||
|
||||
return deferred_push_dlist(info, state);
|
||||
}
|
||||
|
@ -1467,35 +1467,34 @@ static int file_load_with_detect_core_wrapper(
|
||||
const char *path, const char *label,
|
||||
unsigned type, bool is_carchive)
|
||||
{
|
||||
menu_content_ctx_defer_info_t def_info;
|
||||
int ret = 0;
|
||||
char *new_core_path = NULL;
|
||||
const char *menu_path = NULL;
|
||||
const char *menu_label = NULL;
|
||||
core_info_list_t *list = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return menu_cbs_exit();
|
||||
|
||||
{
|
||||
char *menu_path_new = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
new_core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
menu_content_ctx_defer_info_t def_info;
|
||||
char menu_path_new[PATH_MAX_LENGTH];
|
||||
char new_core_path[PATH_MAX_LENGTH];
|
||||
const char *menu_path = NULL;
|
||||
const char *menu_label = NULL;
|
||||
core_info_list_t *list = NULL;
|
||||
new_core_path[0] = menu_path_new[0] = '\0';
|
||||
|
||||
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, NULL, NULL);
|
||||
|
||||
if (!string_is_empty(menu_path))
|
||||
strlcpy(menu_path_new, menu_path, PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcpy(menu_path_new, menu_path, sizeof(menu_path_new));
|
||||
|
||||
if (string_is_equal(menu_label,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE)))
|
||||
fill_pathname_join(menu_path_new, menu->scratch2_buf, menu->scratch_buf,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
fill_pathname_join(menu_path_new,
|
||||
menu->scratch2_buf, menu->scratch_buf, sizeof(menu_path_new));
|
||||
else if (string_is_equal(menu_label,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN)))
|
||||
fill_pathname_join(menu_path_new, menu->scratch2_buf, menu->scratch_buf,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
fill_pathname_join(menu_path_new,
|
||||
menu->scratch2_buf, menu->scratch_buf, sizeof(menu_path_new));
|
||||
|
||||
core_info_get_list(&list);
|
||||
|
||||
@ -1507,7 +1506,7 @@ static int file_load_with_detect_core_wrapper(
|
||||
def_info.len = sizeof(menu->deferred_path);
|
||||
|
||||
if (menu_content_find_first_core(&def_info, false, new_core_path,
|
||||
PATH_MAX_LENGTH * sizeof(char)))
|
||||
sizeof(new_core_path)))
|
||||
ret = -1;
|
||||
|
||||
if ( !is_carchive && !string_is_empty(path)
|
||||
@ -1516,14 +1515,9 @@ static int file_load_with_detect_core_wrapper(
|
||||
menu_path_new, path,
|
||||
sizeof(menu->detect_content_path));
|
||||
|
||||
free(menu_path_new);
|
||||
|
||||
if (enum_label_idx == MENU_ENUM_LABEL_COLLECTION)
|
||||
{
|
||||
free(new_core_path);
|
||||
return generic_action_ok_displaylist_push(path, NULL,
|
||||
NULL, 0, idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST_SET);
|
||||
}
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
@ -1541,10 +1535,8 @@ static int file_load_with_detect_core_wrapper(
|
||||
&content_info,
|
||||
CORE_TYPE_PLAIN,
|
||||
NULL, NULL))
|
||||
{
|
||||
free(new_core_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
content_add_to_playlist(def_info.s);
|
||||
|
||||
ret = 0;
|
||||
@ -1559,7 +1551,6 @@ static int file_load_with_detect_core_wrapper(
|
||||
}
|
||||
}
|
||||
|
||||
free(new_core_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2562,7 +2553,7 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path,
|
||||
struct playlist_entry entry = {0};
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
combined_path[0] = '\0';
|
||||
combined_path[0] = '\0';
|
||||
|
||||
if (!menu)
|
||||
return menu_cbs_exit();
|
||||
@ -2593,7 +2584,7 @@ static int action_ok_audio_add_to_mixer_and_collection_and_play(const char *path
|
||||
struct playlist_entry entry = {0};
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
combined_path[0] = '\0';
|
||||
combined_path[0] = '\0';
|
||||
|
||||
if (!menu)
|
||||
return menu_cbs_exit();
|
||||
@ -3214,12 +3205,12 @@ static int action_ok_path_scan_directory(const char *path,
|
||||
static int action_ok_path_manual_scan_directory(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
char content_dir[PATH_MAX_LENGTH];
|
||||
const char *flush_char = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MANUAL_CONTENT_SCAN_LIST);
|
||||
unsigned flush_type = 0;
|
||||
const char *menu_path = NULL;
|
||||
char content_dir[PATH_MAX_LENGTH];
|
||||
|
||||
content_dir[0] = '\0';
|
||||
content_dir[0] = '\0';
|
||||
|
||||
/* 'Reset' file browser */
|
||||
filebrowser_clear_type();
|
||||
@ -6054,12 +6045,12 @@ static int action_ok_load_archive(const char *path,
|
||||
static int action_ok_load_archive_detect_core(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
char new_core_path[PATH_MAX_LENGTH];
|
||||
menu_content_ctx_defer_info_t def_info;
|
||||
int ret = 0;
|
||||
core_info_list_t *list = NULL;
|
||||
const char *menu_path = NULL;
|
||||
const char *content_path = NULL;
|
||||
char *new_core_path = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
@ -6077,12 +6068,10 @@ static int action_ok_load_archive_detect_core(const char *path,
|
||||
def_info.s = menu->deferred_path;
|
||||
def_info.len = sizeof(menu->deferred_path);
|
||||
|
||||
new_core_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
new_core_path[0] = '\0';
|
||||
|
||||
if (menu_content_find_first_core(&def_info, false,
|
||||
new_core_path, PATH_MAX_LENGTH * sizeof(char)))
|
||||
new_core_path, sizeof(new_core_path)))
|
||||
ret = -1;
|
||||
|
||||
fill_pathname_join(menu->detect_content_path, menu_path, content_path,
|
||||
@ -6119,7 +6108,6 @@ static int action_ok_load_archive_detect_core(const char *path,
|
||||
break;
|
||||
}
|
||||
|
||||
free(new_core_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -972,12 +972,12 @@ static void ozone_cache_footer_labels(ozone_handle_t *ozone)
|
||||
/* Determines the size of all menu elements */
|
||||
static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded)
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char font_path[PATH_MAX_LENGTH];
|
||||
float scale_factor = 0.0f;
|
||||
bool font_inited = false;
|
||||
char *s1 = NULL;
|
||||
|
||||
font_path[0] = '\0';
|
||||
font_path[0] = s1[0]= '\0';
|
||||
|
||||
if (!ozone)
|
||||
return;
|
||||
@ -1033,27 +1033,22 @@ static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded)
|
||||
ozone->pointer_active_delta = CURSOR_ACTIVE_DELTA * scale_factor;
|
||||
|
||||
/* Initialise fonts */
|
||||
s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
s1[0] = '\0';
|
||||
switch (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE))
|
||||
{
|
||||
case RETRO_LANGUAGE_ARABIC:
|
||||
case RETRO_LANGUAGE_PERSIAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(font_path, s1, "fallback-font.ttf", sizeof(font_path));
|
||||
break;
|
||||
case RETRO_LANGUAGE_CHINESE_SIMPLIFIED:
|
||||
case RETRO_LANGUAGE_CHINESE_TRADITIONAL:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(font_path, s1, "chinese-fallback-font.ttf", sizeof(font_path));
|
||||
break;
|
||||
case RETRO_LANGUAGE_KOREAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(font_path, s1, "korean-fallback-font.ttf", sizeof(font_path));
|
||||
break;
|
||||
@ -1069,21 +1064,18 @@ static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded)
|
||||
{
|
||||
case RETRO_LANGUAGE_ARABIC:
|
||||
case RETRO_LANGUAGE_PERSIAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(font_path, s1, "fallback-font.ttf", sizeof(font_path));
|
||||
break;
|
||||
case RETRO_LANGUAGE_CHINESE_SIMPLIFIED:
|
||||
case RETRO_LANGUAGE_CHINESE_TRADITIONAL:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(font_path, s1, "chinese-fallback-font.ttf", sizeof(font_path));
|
||||
break;
|
||||
case RETRO_LANGUAGE_KOREAN:
|
||||
fill_pathname_application_special(s1,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG);
|
||||
fill_pathname_join(font_path, s1, "korean-fallback-font.ttf", sizeof(font_path));
|
||||
break;
|
||||
@ -1091,8 +1083,6 @@ static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded)
|
||||
fill_pathname_join(font_path, ozone->assets_path, "regular.ttf", sizeof(font_path));
|
||||
}
|
||||
|
||||
free(s1);
|
||||
|
||||
font_inited = ozone_init_font(&ozone->fonts.footer,
|
||||
is_threaded, font_path, FONT_SIZE_FOOTER * scale_factor);
|
||||
ozone->has_all_assets = ozone->has_all_assets && font_inited;
|
||||
|
@ -884,32 +884,25 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
|
||||
|
||||
{
|
||||
struct texture_image ti;
|
||||
char *sysname = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *texturepath = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *content_texturepath = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *icons_path = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char sysname[PATH_MAX_LENGTH];
|
||||
char texturepath[PATH_MAX_LENGTH];
|
||||
char content_texturepath[PATH_MAX_LENGTH];
|
||||
char icons_path[PATH_MAX_LENGTH];
|
||||
|
||||
strlcpy(icons_path, ozone->icons_path, PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcpy(icons_path, ozone->icons_path, sizeof(icons_path));
|
||||
|
||||
sysname[0] = texturepath[0] = content_texturepath[0] = '\0';
|
||||
|
||||
fill_pathname_base_noext(sysname, path,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
fill_pathname_base_noext(sysname, path, sizeof(sysname));
|
||||
|
||||
fill_pathname_join_concat(texturepath, icons_path, sysname,
|
||||
".png",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
".png", sizeof(texturepath));
|
||||
|
||||
/* If the playlist icon doesn't exist return default */
|
||||
|
||||
if (!path_is_valid(texturepath))
|
||||
fill_pathname_join_concat(texturepath, icons_path, "default",
|
||||
".png",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
".png", sizeof(texturepath));
|
||||
|
||||
ti.width = 0;
|
||||
ti.height = 0;
|
||||
@ -929,22 +922,18 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
|
||||
}
|
||||
|
||||
fill_pathname_join_delim(sysname, sysname,
|
||||
"content.png", '-',
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(content_texturepath, icons_path,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(content_texturepath, PATH_DEFAULT_SLASH(),
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(content_texturepath, sysname, PATH_MAX_LENGTH * sizeof(char));
|
||||
"content.png", '-', sizeof(sysname));
|
||||
strlcat(content_texturepath, icons_path, sizeof(content_texturepath));
|
||||
strlcat(content_texturepath, PATH_DEFAULT_SLASH(), sizeof(content_texturepath));
|
||||
strlcat(content_texturepath, sysname, sizeof(content_texturepath));
|
||||
|
||||
/* If the content icon doesn't exist return default-content */
|
||||
if (!path_is_valid(content_texturepath))
|
||||
{
|
||||
strlcat(icons_path,
|
||||
PATH_DEFAULT_SLASH() "default", PATH_MAX_LENGTH * sizeof(char));
|
||||
PATH_DEFAULT_SLASH() "default", sizeof(icons_path));
|
||||
fill_pathname_join_delim(content_texturepath, icons_path,
|
||||
"content.png", '-',
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
"content.png", '-', sizeof(content_texturepath));
|
||||
}
|
||||
|
||||
if (image_texture_load(&ti, content_texturepath))
|
||||
@ -972,11 +961,6 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
|
||||
* dereferencing in case of unknown errors... */
|
||||
node->console_name = strdup(
|
||||
console_name ? console_name : path);
|
||||
|
||||
free(sysname);
|
||||
free(texturepath);
|
||||
free(content_texturepath);
|
||||
free(icons_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1765,8 +1765,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
|
||||
|
||||
if (menu_dynamic_wallpaper_enable)
|
||||
{
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char *path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char path[PATH_MAX_LENGTH];
|
||||
char *tmp = string_replace_substring(xmb->title_name, "/", " ");
|
||||
|
||||
path[0] = '\0';
|
||||
@ -1777,14 +1776,14 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
|
||||
path,
|
||||
dir_dynamic_wallpapers,
|
||||
tmp,
|
||||
path_size);
|
||||
sizeof(path));
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
strlcat(path, ".png", path_size);
|
||||
strlcat(path, ".png", sizeof(path));
|
||||
|
||||
if (!path_is_valid(path))
|
||||
fill_pathname_application_special(path, path_size,
|
||||
fill_pathname_application_special(path, sizeof(path),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG);
|
||||
|
||||
if (!string_is_equal(path, xmb->bg_file_path))
|
||||
@ -1799,8 +1798,6 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
|
||||
xmb->bg_file_path = strdup(path);
|
||||
}
|
||||
}
|
||||
|
||||
free(path);
|
||||
}
|
||||
|
||||
end = file_list_get_size(list);
|
||||
@ -2163,41 +2160,30 @@ static void xmb_context_reset_horizontal_list(
|
||||
if (!path)
|
||||
continue;
|
||||
|
||||
if (!string_ends_with_size(path, ".lpl",
|
||||
if (string_ends_with_size(path, ".lpl",
|
||||
strlen(path), STRLEN_CONST(".lpl")))
|
||||
continue;
|
||||
|
||||
{
|
||||
struct texture_image ti;
|
||||
char *sysname = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *iconpath = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *texturepath = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *content_texturepath = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char sysname[PATH_MAX_LENGTH];
|
||||
char iconpath[PATH_MAX_LENGTH];
|
||||
char texturepath[PATH_MAX_LENGTH];
|
||||
char content_texturepath[PATH_MAX_LENGTH];
|
||||
|
||||
iconpath[0] = sysname[0] =
|
||||
iconpath[0] = sysname[0] =
|
||||
texturepath[0] = content_texturepath[0] = '\0';
|
||||
|
||||
fill_pathname_base_noext(sysname, path,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
fill_pathname_application_special(iconpath,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_base_noext(sysname, path, sizeof(sysname));
|
||||
fill_pathname_application_special(iconpath, sizeof(iconpath),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
|
||||
fill_pathname_join_concat(texturepath, iconpath, sysname,
|
||||
".png",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
".png", sizeof(texturepath));
|
||||
|
||||
/* If the playlist icon doesn't exist return default */
|
||||
|
||||
if (!path_is_valid(texturepath))
|
||||
fill_pathname_join_concat(texturepath, iconpath, "default",
|
||||
".png",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
".png", sizeof(texturepath));
|
||||
|
||||
ti.width = 0;
|
||||
ti.height = 0;
|
||||
@ -2216,10 +2202,10 @@ static void xmb_context_reset_horizontal_list(
|
||||
image_texture_free(&ti);
|
||||
}
|
||||
|
||||
fill_pathname_join_delim(sysname, sysname, "content.png",
|
||||
'-', PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(content_texturepath, iconpath, PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(content_texturepath, sysname, PATH_MAX_LENGTH * sizeof(char));
|
||||
fill_pathname_join_delim(sysname, sysname, "content.png", '-',
|
||||
sizeof(sysname));
|
||||
strlcat(content_texturepath, iconpath, sizeof(content_texturepath));
|
||||
strlcat(content_texturepath, sysname, sizeof(content_texturepath));
|
||||
|
||||
/* If the content icon doesn't exist return default-content */
|
||||
|
||||
@ -2242,11 +2228,6 @@ static void xmb_context_reset_horizontal_list(
|
||||
|
||||
image_texture_free(&ti);
|
||||
}
|
||||
|
||||
free(sysname);
|
||||
free(iconpath);
|
||||
free(texturepath);
|
||||
free(content_texturepath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6067,8 +6048,8 @@ static void xmb_context_reset_background(const char *iconpath)
|
||||
static void xmb_context_reset_internal(xmb_handle_t *xmb,
|
||||
bool is_threaded, bool reinit_textures)
|
||||
{
|
||||
char iconpath[PATH_MAX_LENGTH];
|
||||
char bg_file_path[PATH_MAX_LENGTH] = {0};
|
||||
char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
iconpath[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(bg_file_path,
|
||||
@ -6081,8 +6062,7 @@ static void xmb_context_reset_internal(xmb_handle_t *xmb,
|
||||
xmb->bg_file_path = strdup(bg_file_path);
|
||||
}
|
||||
|
||||
fill_pathname_application_special(iconpath,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(iconpath, sizeof(iconpath),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
|
||||
xmb_layout(xmb);
|
||||
@ -6131,8 +6111,6 @@ static void xmb_context_reset_internal(xmb_handle_t *xmb,
|
||||
}
|
||||
|
||||
xmb_update_savestate_thumbnail_image(xmb);
|
||||
|
||||
free(iconpath);
|
||||
}
|
||||
|
||||
static void xmb_context_reset(void *data, bool is_threaded)
|
||||
|
@ -867,7 +867,7 @@ static void task_load_handler(retro_task_t *task)
|
||||
{
|
||||
if (state->autoload)
|
||||
{
|
||||
char *msg = (char*)malloc(8192 * sizeof(char));
|
||||
char msg[8192];
|
||||
|
||||
msg[0] = '\0';
|
||||
|
||||
@ -878,7 +878,6 @@ static void task_load_handler(retro_task_t *task)
|
||||
state->path,
|
||||
msg_hash_to_str(MSG_FAILED));
|
||||
task_set_error(task, strdup(msg));
|
||||
free(msg);
|
||||
}
|
||||
else
|
||||
task_set_error(task, strdup(msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE)));
|
||||
@ -891,15 +890,14 @@ static void task_load_handler(retro_task_t *task)
|
||||
|
||||
if (state->bytes_read == state->size)
|
||||
{
|
||||
size_t sizeof_msg = 8192;
|
||||
char *msg = (char*)malloc(sizeof_msg * sizeof(char));
|
||||
char msg[8192];
|
||||
|
||||
msg[0] = '\0';
|
||||
|
||||
task_free_title(task);
|
||||
|
||||
if (state->autoload)
|
||||
snprintf(msg, sizeof_msg,
|
||||
snprintf(msg, sizeof(msg),
|
||||
"%s \"%s\" %s.",
|
||||
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FROM),
|
||||
state->path,
|
||||
@ -908,9 +906,9 @@ static void task_load_handler(retro_task_t *task)
|
||||
{
|
||||
if (state->state_slot < 0)
|
||||
strlcpy(msg, msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT_AUTO),
|
||||
sizeof_msg);
|
||||
sizeof(msg));
|
||||
else
|
||||
snprintf(msg, sizeof_msg,
|
||||
snprintf(msg, sizeof(msg),
|
||||
msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT),
|
||||
state->state_slot);
|
||||
|
||||
@ -919,7 +917,6 @@ static void task_load_handler(retro_task_t *task)
|
||||
if (!task_get_mute(task))
|
||||
task_set_title(task, strdup(msg));
|
||||
|
||||
free(msg);
|
||||
task_load_handler_finished(task, state);
|
||||
|
||||
return;
|
||||
@ -1581,40 +1578,31 @@ static bool dump_to_file_desperate(const void *data,
|
||||
{
|
||||
time_t time_;
|
||||
struct tm tm_;
|
||||
char *timebuf;
|
||||
char *path;
|
||||
char *application_data = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char timebuf[256];
|
||||
char path[PATH_MAX_LENGTH];
|
||||
char application_data[PATH_MAX_LENGTH];
|
||||
|
||||
application_data[0] = '\0';
|
||||
path [0] = '\0';
|
||||
timebuf [0] = '\0';
|
||||
|
||||
if (!fill_pathname_application_data(application_data,
|
||||
PATH_MAX_LENGTH * sizeof(char)))
|
||||
{
|
||||
free(application_data);
|
||||
sizeof(application_data)))
|
||||
return false;
|
||||
}
|
||||
|
||||
time(&time_);
|
||||
|
||||
timebuf = (char*)malloc(256 * sizeof(char));
|
||||
timebuf[0] = '\0';
|
||||
|
||||
rtime_localtime(&time_, &tm_);
|
||||
|
||||
strftime(timebuf,
|
||||
256 * sizeof(char),
|
||||
"%Y-%m-%d-%H-%M-%S", &tm_);
|
||||
|
||||
path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
path[0] = '\0';
|
||||
snprintf(path,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
snprintf(path, sizeof(path),
|
||||
"%s/RetroArch-recovery-%u%s",
|
||||
application_data, type,
|
||||
timebuf);
|
||||
|
||||
free(application_data);
|
||||
free(timebuf);
|
||||
|
||||
/* Fallback (emergency) saves are always
|
||||
* uncompressed
|
||||
* > If a regular save fails, then the host
|
||||
@ -1625,13 +1613,9 @@ static bool dump_to_file_desperate(const void *data,
|
||||
* complicate matters by introducing zlib
|
||||
* compression overheads */
|
||||
if (!filestream_write_file(path, data, size))
|
||||
{
|
||||
free(path);
|
||||
return false;
|
||||
}
|
||||
|
||||
RARCH_WARN("[SRAM]: Succeeded in saving RAM data to \"%s\".\n", path);
|
||||
free(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1733,8 +1717,7 @@ bool event_load_save_files(bool is_sram_load_disabled)
|
||||
void path_init_savefile_rtc(const char *savefile_path)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
char *savefile_name_rtc = (char*)
|
||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char savefile_name_rtc[PATH_MAX_LENGTH];
|
||||
|
||||
savefile_name_rtc[0] = '\0';
|
||||
|
||||
@ -1745,9 +1728,8 @@ void path_init_savefile_rtc(const char *savefile_path)
|
||||
attr.i = RETRO_MEMORY_RTC;
|
||||
fill_pathname(savefile_name_rtc,
|
||||
savefile_path, ".rtc",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
sizeof(savefile_name_rtc));
|
||||
string_list_append(task_save_files, savefile_name_rtc, attr);
|
||||
free(savefile_name_rtc);
|
||||
}
|
||||
|
||||
void path_deinit_savefile(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user