mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
Clean up more string variables on heap; move to stack
This commit is contained in:
parent
0f4470dabb
commit
0c5611d10e
@ -214,44 +214,43 @@ void fill_pathname_application_special(char *s,
|
|||||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_SOUNDS:
|
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_SOUNDS:
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
|
char s1[PATH_MAX_LENGTH];
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
const char *menu_ident = settings->arrays.menu_driver;
|
const char *menu_ident = settings->arrays.menu_driver;
|
||||||
const char *dir_assets = settings->paths.directory_assets;
|
const char *dir_assets = settings->paths.directory_assets;
|
||||||
char *s1 = (char*)calloc(
|
|
||||||
1, PATH_MAX_LENGTH * sizeof(char));
|
s1[0] = '\0';
|
||||||
|
|
||||||
if (string_is_equal(menu_ident, "xmb"))
|
if (string_is_equal(menu_ident, "xmb"))
|
||||||
{
|
{
|
||||||
fill_pathname_application_special(s1, PATH_MAX_LENGTH * sizeof(char), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB);
|
fill_pathname_application_special(s1, sizeof(s1),
|
||||||
|
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB);
|
||||||
|
|
||||||
if (!string_is_empty(s1))
|
if (!string_is_empty(s1))
|
||||||
strlcat(s1, "/sounds", PATH_MAX_LENGTH * sizeof(char));
|
strlcat(s1, "/sounds", sizeof(s1));
|
||||||
}
|
}
|
||||||
else if (string_is_equal(menu_ident, "glui"))
|
else if (string_is_equal(menu_ident, "glui"))
|
||||||
{
|
{
|
||||||
fill_pathname_application_special(s1, PATH_MAX_LENGTH * sizeof(char), APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI);
|
fill_pathname_application_special(s1, sizeof(s1),
|
||||||
|
APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI);
|
||||||
|
|
||||||
if (!string_is_empty(s1))
|
if (!string_is_empty(s1))
|
||||||
strlcat(s1, "/sounds", PATH_MAX_LENGTH * sizeof(char));
|
strlcat(s1, "/sounds", sizeof(s1));
|
||||||
}
|
}
|
||||||
else if (string_is_equal(menu_ident, "ozone"))
|
else if (string_is_equal(menu_ident, "ozone"))
|
||||||
{
|
{
|
||||||
fill_pathname_application_special(s1, PATH_MAX_LENGTH * sizeof(char), APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE);
|
fill_pathname_application_special(s1, sizeof(s1),
|
||||||
|
APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE);
|
||||||
|
|
||||||
if (!string_is_empty(s1))
|
if (!string_is_empty(s1))
|
||||||
strlcat(s1, "/sounds", PATH_MAX_LENGTH * sizeof(char));
|
strlcat(s1, "/sounds", sizeof(s1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string_is_empty(s1))
|
if (string_is_empty(s1))
|
||||||
{
|
|
||||||
fill_pathname_join(
|
fill_pathname_join(
|
||||||
s1, dir_assets, "sounds",
|
s1, dir_assets, "sounds", sizeof(s1));
|
||||||
PATH_MAX_LENGTH * sizeof(char)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
strlcpy(s, s1, len);
|
strlcpy(s, s1, len);
|
||||||
free(s1);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,8 +602,8 @@ bool video_shader_write_preset(const char *path,
|
|||||||
"presets",
|
"presets",
|
||||||
sizeof(preset_dir));
|
sizeof(preset_dir));
|
||||||
|
|
||||||
strlcpy(clean_shader_path, shader->path, PATH_MAX_LENGTH);
|
strlcpy(clean_shader_path, shader->path, sizeof(clean_shader_path));
|
||||||
path_resolve_realpath(clean_shader_path, PATH_MAX_LENGTH, false);
|
path_resolve_realpath(clean_shader_path, sizeof(clean_shader_path), false);
|
||||||
|
|
||||||
if (string_is_empty(shader->path))
|
if (string_is_empty(shader->path))
|
||||||
reference = false;
|
reference = false;
|
||||||
@ -627,8 +627,8 @@ bool video_shader_write_preset(const char *path,
|
|||||||
size_t len = STRLEN_CONST("#reference \"");
|
size_t len = STRLEN_CONST("#reference \"");
|
||||||
char *preset_ref = buf + len;
|
char *preset_ref = buf + len;
|
||||||
|
|
||||||
strlcpy(clean_path, path, PATH_MAX_LENGTH);
|
strlcpy(clean_path, path, sizeof(clean_path));
|
||||||
path_resolve_realpath(clean_path, PATH_MAX_LENGTH, false);
|
path_resolve_realpath(clean_path, sizeof(clean_path), false);
|
||||||
|
|
||||||
path_relative_to(preset_ref, clean_shader_path, clean_path, PATH_MAX_LENGTH);
|
path_relative_to(preset_ref, clean_shader_path, clean_path, PATH_MAX_LENGTH);
|
||||||
len += strlen(preset_ref);
|
len += strlen(preset_ref);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user