mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Reduce more stack usage for offending functions
This commit is contained in:
parent
8654f124d1
commit
12957e461d
@ -755,11 +755,12 @@ void audio_driver_dsp_filter_init(const char *device)
|
|||||||
{
|
{
|
||||||
struct string_list *plugs = NULL;
|
struct string_list *plugs = NULL;
|
||||||
#if defined(HAVE_DYLIB) && !defined(HAVE_FILTERS_BUILTIN)
|
#if defined(HAVE_DYLIB) && !defined(HAVE_FILTERS_BUILTIN)
|
||||||
char *basedir = (char*)calloc(PATH_MAX_LENGTH, sizeof(*basedir));
|
char *basedir = (char*)calloc(PATH_MAX_LENGTH, sizeof(*basedir));
|
||||||
char *ext_name = (char*)calloc(PATH_MAX_LENGTH, sizeof(*ext_name));
|
char *ext_name = (char*)calloc(PATH_MAX_LENGTH, sizeof(*ext_name));
|
||||||
fill_pathname_basedir(basedir, device, sizeof(basedir));
|
size_t str_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
|
fill_pathname_basedir(basedir, device, str_size);
|
||||||
|
|
||||||
if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name)))
|
if (!frontend_driver_get_core_extension(ext_name, str_size))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
plugs = dir_list_new(basedir, ext_name, false, true, false, false);
|
plugs = dir_list_new(basedir, ext_name, false, true, false, false);
|
||||||
|
151
command.c
151
command.c
@ -1075,31 +1075,33 @@ static void command_event_init_cheats(void)
|
|||||||
static void command_event_load_auto_state(void)
|
static void command_event_load_auto_state(void)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
char msg[128] = {0};
|
char msg[128] = {0};
|
||||||
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
|
char *savestate_name_auto = (char*)calloc(PATH_MAX_LENGTH,
|
||||||
settings_t *settings = config_get_ptr();
|
sizeof(*savestate_name_auto));
|
||||||
global_t *global = global_get_ptr();
|
size_t savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
||||||
return;
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
if (settings->bools.cheevos_hardcore_mode_enable)
|
if (settings->bools.cheevos_hardcore_mode_enable)
|
||||||
return;
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!settings->bools.savestate_auto_load)
|
if (!settings->bools.savestate_auto_load)
|
||||||
return;
|
goto error;
|
||||||
|
|
||||||
if (global)
|
if (global)
|
||||||
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
||||||
file_path_str(FILE_PATH_AUTO_EXTENSION),
|
file_path_str(FILE_PATH_AUTO_EXTENSION),
|
||||||
sizeof(savestate_name_auto));
|
savestate_name_auto_size);
|
||||||
|
|
||||||
if (!path_file_exists(savestate_name_auto))
|
if (!path_file_exists(savestate_name_auto))
|
||||||
return;
|
goto error;
|
||||||
|
|
||||||
ret = content_load_state(savestate_name_auto, false, true);
|
ret = content_load_state(savestate_name_auto, false, true);
|
||||||
|
|
||||||
@ -1110,20 +1112,28 @@ static void command_event_load_auto_state(void)
|
|||||||
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FROM),
|
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FROM),
|
||||||
savestate_name_auto, ret ? "succeeded" : "failed");
|
savestate_name_auto, ret ? "succeeded" : "failed");
|
||||||
RARCH_LOG("%s\n", msg);
|
RARCH_LOG("%s\n", msg);
|
||||||
|
|
||||||
|
free(savestate_name_auto);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
error:
|
||||||
|
free(savestate_name_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void command_event_set_savestate_auto_index(void)
|
static void command_event_set_savestate_auto_index(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char state_dir[PATH_MAX_LENGTH] = {0};
|
char *state_dir = (char*)calloc(PATH_MAX_LENGTH, sizeof(*state_dir));
|
||||||
char state_base[PATH_MAX_LENGTH] = {0};
|
char *state_base = (char*)calloc(PATH_MAX_LENGTH, sizeof(*state_base));
|
||||||
struct string_list *dir_list = NULL;
|
size_t state_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
unsigned max_idx = 0;
|
struct string_list *dir_list = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
unsigned max_idx = 0;
|
||||||
global_t *global = global_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
if (!settings->bools.savestate_auto_index)
|
if (!settings->bools.savestate_auto_index)
|
||||||
return;
|
goto error;
|
||||||
|
|
||||||
if (global)
|
if (global)
|
||||||
{
|
{
|
||||||
@ -1134,15 +1144,15 @@ static void command_event_set_savestate_auto_index(void)
|
|||||||
* /foo/path/content.state%d, where %d is the largest number available.
|
* /foo/path/content.state%d, where %d is the largest number available.
|
||||||
*/
|
*/
|
||||||
fill_pathname_basedir(state_dir, global->name.savestate,
|
fill_pathname_basedir(state_dir, global->name.savestate,
|
||||||
sizeof(state_dir));
|
state_size);
|
||||||
fill_pathname_base(state_base, global->name.savestate,
|
fill_pathname_base(state_base, global->name.savestate,
|
||||||
sizeof(state_base));
|
state_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL);
|
dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL);
|
||||||
|
|
||||||
if (!dir_list)
|
if (!dir_list)
|
||||||
return;
|
goto error;
|
||||||
|
|
||||||
for (i = 0; i < dir_list->size; i++)
|
for (i = 0; i < dir_list->size; i++)
|
||||||
{
|
{
|
||||||
@ -1172,6 +1182,14 @@ static void command_event_set_savestate_auto_index(void)
|
|||||||
RARCH_LOG("%s: #%d\n",
|
RARCH_LOG("%s: #%d\n",
|
||||||
msg_hash_to_str(MSG_FOUND_LAST_STATE_SLOT),
|
msg_hash_to_str(MSG_FOUND_LAST_STATE_SLOT),
|
||||||
max_idx);
|
max_idx);
|
||||||
|
|
||||||
|
free(state_dir);
|
||||||
|
free(state_base);
|
||||||
|
return;
|
||||||
|
|
||||||
|
error:
|
||||||
|
free(state_dir);
|
||||||
|
free(state_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool event_init_content(void)
|
static bool event_init_content(void)
|
||||||
@ -1297,33 +1315,36 @@ static void command_event_restore_remaps(void)
|
|||||||
|
|
||||||
static bool command_event_save_auto_state(void)
|
static bool command_event_save_auto_state(void)
|
||||||
{
|
{
|
||||||
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
|
bool ret = false;
|
||||||
bool ret = false;
|
bool contentless = false;
|
||||||
bool contentless = false;
|
bool is_inited = false;
|
||||||
bool is_inited = false;
|
char *savestate_name_auto = (char*)
|
||||||
settings_t *settings = config_get_ptr();
|
calloc(PATH_MAX_LENGTH, sizeof(*savestate_name_auto));
|
||||||
global_t *global = global_get_ptr();
|
size_t
|
||||||
|
savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
if (!settings || !settings->bools.savestate_auto_save)
|
if (!settings || !settings->bools.savestate_auto_save)
|
||||||
return false;
|
goto error;
|
||||||
if (!global)
|
if (!global)
|
||||||
return false;
|
goto error;
|
||||||
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
||||||
return false;
|
goto error;
|
||||||
|
|
||||||
content_get_status(&contentless, &is_inited);
|
content_get_status(&contentless, &is_inited);
|
||||||
|
|
||||||
if (contentless)
|
if (contentless)
|
||||||
return false;
|
goto error;
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
if (settings->bools.cheevos_hardcore_mode_enable)
|
if (settings->bools.cheevos_hardcore_mode_enable)
|
||||||
return false;
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
||||||
file_path_str(FILE_PATH_AUTO_EXTENSION),
|
file_path_str(FILE_PATH_AUTO_EXTENSION),
|
||||||
sizeof(savestate_name_auto));
|
savestate_name_auto_size);
|
||||||
|
|
||||||
ret = content_save_state((const char*)savestate_name_auto, true, true);
|
ret = content_save_state((const char*)savestate_name_auto, true, true);
|
||||||
RARCH_LOG("%s \"%s\" %s.\n",
|
RARCH_LOG("%s \"%s\" %s.\n",
|
||||||
@ -1331,7 +1352,12 @@ static bool command_event_save_auto_state(void)
|
|||||||
savestate_name_auto, ret ?
|
savestate_name_auto, ret ?
|
||||||
"succeeded" : "failed");
|
"succeeded" : "failed");
|
||||||
|
|
||||||
|
free(savestate_name_auto);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
free(savestate_name_auto);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool command_event_save_config(const char *config_path,
|
static bool command_event_save_config(const char *config_path,
|
||||||
@ -1364,29 +1390,30 @@ static bool command_event_save_config(const char *config_path,
|
|||||||
**/
|
**/
|
||||||
static bool command_event_save_core_config(void)
|
static bool command_event_save_core_config(void)
|
||||||
{
|
{
|
||||||
char config_dir[PATH_MAX_LENGTH];
|
|
||||||
char config_name[PATH_MAX_LENGTH];
|
|
||||||
char config_path[PATH_MAX_LENGTH];
|
|
||||||
char msg[128];
|
char msg[128];
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
bool found_path = false;
|
bool found_path = false;
|
||||||
bool overrides_active = false;
|
bool overrides_active = false;
|
||||||
settings_t *settings = config_get_ptr();
|
char *config_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
char *config_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
char *config_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
size_t config_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
config_dir[0] = config_name[0] =
|
config_dir[0] = config_name[0] =
|
||||||
config_path[0] = msg[0] = '\0';
|
config_path[0] = msg[0] = '\0';
|
||||||
|
|
||||||
if (!string_is_empty(settings->paths.directory_menu_config))
|
if (!string_is_empty(settings->paths.directory_menu_config))
|
||||||
strlcpy(config_dir, settings->paths.directory_menu_config,
|
strlcpy(config_dir, settings->paths.directory_menu_config,
|
||||||
sizeof(config_dir));
|
config_size);
|
||||||
else if (!path_is_empty(RARCH_PATH_CONFIG)) /* Fallback */
|
else if (!path_is_empty(RARCH_PATH_CONFIG)) /* Fallback */
|
||||||
fill_pathname_basedir(config_dir, path_get(RARCH_PATH_CONFIG),
|
fill_pathname_basedir(config_dir, path_get(RARCH_PATH_CONFIG),
|
||||||
sizeof(config_dir));
|
config_size);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true);
|
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true);
|
||||||
RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
|
RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
|
||||||
return false;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Infer file name based on libretro core. */
|
/* Infer file name based on libretro core. */
|
||||||
@ -1403,10 +1430,10 @@ static bool command_event_save_core_config(void)
|
|||||||
fill_pathname_base_noext(
|
fill_pathname_base_noext(
|
||||||
config_name,
|
config_name,
|
||||||
path_get(RARCH_PATH_CORE),
|
path_get(RARCH_PATH_CORE),
|
||||||
sizeof(config_name));
|
config_size);
|
||||||
|
|
||||||
fill_pathname_join(config_path, config_dir, config_name,
|
fill_pathname_join(config_path, config_dir, config_name,
|
||||||
sizeof(config_path));
|
config_size);
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
snprintf(tmp, sizeof(tmp), "-%u%s",
|
snprintf(tmp, sizeof(tmp), "-%u%s",
|
||||||
@ -1417,7 +1444,7 @@ static bool command_event_save_core_config(void)
|
|||||||
file_path_str(FILE_PATH_CONFIG_EXTENSION),
|
file_path_str(FILE_PATH_CONFIG_EXTENSION),
|
||||||
sizeof(tmp));
|
sizeof(tmp));
|
||||||
|
|
||||||
strlcat(config_path, tmp, sizeof(config_path));
|
strlcat(config_path, tmp, config_size);
|
||||||
if (!path_file_exists(config_path))
|
if (!path_file_exists(config_path))
|
||||||
{
|
{
|
||||||
found_path = true;
|
found_path = true;
|
||||||
@ -1433,9 +1460,9 @@ static bool command_event_save_core_config(void)
|
|||||||
msg_hash_to_str(MSG_CANNOT_INFER_NEW_CONFIG_PATH));
|
msg_hash_to_str(MSG_CANNOT_INFER_NEW_CONFIG_PATH));
|
||||||
fill_dated_filename(config_name,
|
fill_dated_filename(config_name,
|
||||||
file_path_str(FILE_PATH_CONFIG_EXTENSION),
|
file_path_str(FILE_PATH_CONFIG_EXTENSION),
|
||||||
sizeof(config_name));
|
config_size);
|
||||||
fill_pathname_join(config_path, config_dir, config_name,
|
fill_pathname_join(config_path, config_dir, config_name,
|
||||||
sizeof(config_path));
|
config_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rarch_ctl(RARCH_CTL_IS_OVERRIDES_ACTIVE, NULL))
|
if (rarch_ctl(RARCH_CTL_IS_OVERRIDES_ACTIVE, NULL))
|
||||||
@ -1455,7 +1482,17 @@ static bool command_event_save_core_config(void)
|
|||||||
rarch_ctl(RARCH_CTL_SET_OVERRIDES_ACTIVE, NULL);
|
rarch_ctl(RARCH_CTL_SET_OVERRIDES_ACTIVE, NULL);
|
||||||
else
|
else
|
||||||
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
||||||
|
|
||||||
|
free(config_dir);
|
||||||
|
free(config_name);
|
||||||
|
free(config_path);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
error:
|
||||||
|
free(config_dir);
|
||||||
|
free(config_name);
|
||||||
|
free(config_path);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1546,13 +1583,14 @@ static void command_event_undo_load_state(char *s, size_t len)
|
|||||||
static bool command_event_main_state(unsigned cmd)
|
static bool command_event_main_state(unsigned cmd)
|
||||||
{
|
{
|
||||||
retro_ctx_size_info_t info;
|
retro_ctx_size_info_t info;
|
||||||
char path[PATH_MAX_LENGTH];
|
|
||||||
char msg[128];
|
char msg[128];
|
||||||
|
char *state_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
size_t state_path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
bool push_msg = true;
|
bool push_msg = true;
|
||||||
|
|
||||||
path[0] = msg[0] = '\0';
|
state_path[0] = msg[0] = '\0';
|
||||||
|
|
||||||
if (global)
|
if (global)
|
||||||
{
|
{
|
||||||
@ -1560,13 +1598,13 @@ static bool command_event_main_state(unsigned cmd)
|
|||||||
int state_slot = settings->ints.state_slot;
|
int state_slot = settings->ints.state_slot;
|
||||||
|
|
||||||
if (state_slot > 0)
|
if (state_slot > 0)
|
||||||
snprintf(path, sizeof(path), "%s%d",
|
snprintf(state_path, state_path_size, "%s%d",
|
||||||
global->name.savestate, state_slot);
|
global->name.savestate, state_slot);
|
||||||
else if (state_slot < 0)
|
else if (state_slot < 0)
|
||||||
fill_pathname_join_delim(path,
|
fill_pathname_join_delim(state_path,
|
||||||
global->name.savestate, "auto", '.', sizeof(path));
|
global->name.savestate, "auto", '.', state_path_size);
|
||||||
else
|
else
|
||||||
strlcpy(path, global->name.savestate, sizeof(path));
|
strlcpy(state_path, global->name.savestate, state_path_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
core_serialize_size(&info);
|
core_serialize_size(&info);
|
||||||
@ -1576,12 +1614,12 @@ static bool command_event_main_state(unsigned cmd)
|
|||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case CMD_EVENT_SAVE_STATE:
|
case CMD_EVENT_SAVE_STATE:
|
||||||
content_save_state(path, true, false);
|
content_save_state(state_path, true, false);
|
||||||
ret = true;
|
ret = true;
|
||||||
push_msg = false;
|
push_msg = false;
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_LOAD_STATE:
|
case CMD_EVENT_LOAD_STATE:
|
||||||
if (content_load_state(path, false, false))
|
if (content_load_state(state_path, false, false))
|
||||||
{
|
{
|
||||||
ret = true;
|
ret = true;
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
@ -1608,6 +1646,7 @@ static bool command_event_main_state(unsigned cmd)
|
|||||||
runloop_msg_queue_push(msg, 2, 180, true);
|
runloop_msg_queue_push(msg, 2, 180, true);
|
||||||
RARCH_LOG("%s\n", msg);
|
RARCH_LOG("%s\n", msg);
|
||||||
|
|
||||||
|
free(state_path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user