mirror of
https://github.com/libretro/RetroArch
synced 2025-02-26 15:39:55 +00:00
If we already know the length of the string, use strldup instead.
Avoids the internal strlen call inside strdup, and strdup is a deprecated function starting from MSVC2005 anyways. NOTE: Do NOT pass STRLEN_CONST as n parameter to strldup, it needs to be at least +1 character higher than the strlen return value of the same string
This commit is contained in:
parent
5bb3fbab93
commit
575e331fd1
@ -576,7 +576,7 @@ static bool core_updater_list_set_core_info(
|
||||
if (!string_is_empty(core_info->description))
|
||||
entry->description = strdup(core_info->description);
|
||||
else
|
||||
entry->description = strdup("");
|
||||
entry->description = strldup("", sizeof(""));
|
||||
|
||||
/* licenses_list */
|
||||
if (!string_is_empty(core_info->licenses))
|
||||
@ -592,7 +592,7 @@ static bool core_updater_list_set_core_info(
|
||||
* cores must have a valid/complete core info file) */
|
||||
entry->display_name = strdup(filename_str);
|
||||
entry->is_experimental = true;
|
||||
entry->description = strdup("");
|
||||
entry->description = strldup("", sizeof(""));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -211,7 +211,7 @@ static char *config_file_extract_value(char *line)
|
||||
line++;
|
||||
|
||||
/* Note: From this point on, an empty value
|
||||
* string is valid - and in this case, strdup("")
|
||||
* string is valid - and in this case, strldup("", sizeof(""))
|
||||
* will be returned
|
||||
* > If we instead return NULL, the the entry
|
||||
* is ignored completely - which means we cannot
|
||||
@ -254,7 +254,7 @@ static char *config_file_extract_value(char *line)
|
||||
return strdup(value);
|
||||
}
|
||||
|
||||
return strdup("");
|
||||
return strldup("", sizeof(""));
|
||||
}
|
||||
|
||||
/* Move semantics? */
|
||||
|
@ -4350,7 +4350,7 @@ static void ozone_init_horizontal_list(ozone_handle_t *ozone,
|
||||
info.path = strdup(dir_playlist);
|
||||
info.label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB));
|
||||
info.exts = strdup("lpl");
|
||||
info.exts = strldup("lpl", sizeof("lpl"));
|
||||
info.type_default = FILE_TYPE_PLAIN;
|
||||
info.enum_idx = MENU_ENUM_LABEL_PLAYLISTS_TAB;
|
||||
|
||||
@ -10847,7 +10847,7 @@ static bool ozone_menu_init_list(void *data)
|
||||
|
||||
info.label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU));
|
||||
info.exts = strdup("lpl");
|
||||
info.exts = strldup("lpl", sizeof("lpl"));
|
||||
info.type_default = FILE_TYPE_PLAIN;
|
||||
info.enum_idx = MENU_ENUM_LABEL_MAIN_MENU;
|
||||
|
||||
|
@ -2210,7 +2210,7 @@ static void xmb_init_horizontal_list(xmb_handle_t *xmb)
|
||||
info.path = strdup(dir_playlist);
|
||||
info.label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB));
|
||||
info.exts = strdup("lpl");
|
||||
info.exts = strldup("lpl", sizeof("lpl"));
|
||||
info.type_default = FILE_TYPE_PLAIN;
|
||||
info.enum_idx = MENU_ENUM_LABEL_PLAYLISTS_TAB;
|
||||
|
||||
@ -7622,7 +7622,7 @@ static bool xmb_menu_init_list(void *data)
|
||||
|
||||
info.label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU));
|
||||
info.exts = strdup("lpl");
|
||||
info.exts = strldup("lpl", sizeof("lpl"));
|
||||
info.type_default = FILE_TYPE_PLAIN;
|
||||
info.enum_idx = MENU_ENUM_LABEL_MAIN_MENU;
|
||||
|
||||
|
@ -13724,7 +13724,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
if (info->path)
|
||||
free(info->path);
|
||||
info->type_default = FILE_TYPE_RDB;
|
||||
info->exts = strdup(".rdb");
|
||||
info->exts = strldup(".rdb", sizeof(".rdb"));
|
||||
info->enum_idx = MENU_ENUM_LABEL_PLAYLISTS_TAB;
|
||||
load_content = false;
|
||||
use_filebrowser = true;
|
||||
@ -13740,7 +13740,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
if (info->path)
|
||||
free(info->path);
|
||||
info->type_default = FILE_TYPE_CURSOR;
|
||||
info->exts = strdup("dbc");
|
||||
info->exts = strldup("dbc", sizeof("dbc"));
|
||||
load_content = false;
|
||||
use_filebrowser = true;
|
||||
info->path = strdup(settings->paths.directory_cursor);
|
||||
@ -13923,51 +13923,51 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
{
|
||||
case DISPLAYLIST_VIDEO_FILTERS:
|
||||
info->type_default = FILE_TYPE_VIDEOFILTER;
|
||||
info->exts = strdup("filt");
|
||||
info->exts = strldup("filt", sizeof("filt"));
|
||||
break;
|
||||
case DISPLAYLIST_CONFIG_FILES:
|
||||
info->type_default = FILE_TYPE_CONFIG;
|
||||
info->exts = strdup("cfg");
|
||||
info->exts = strldup("cfg", sizeof("cfg"));
|
||||
break;
|
||||
case DISPLAYLIST_REMAP_FILES:
|
||||
info->type_default = FILE_TYPE_REMAP;
|
||||
info->exts = strdup("rmp");
|
||||
info->exts = strldup("rmp", sizeof("rmp"));
|
||||
break;
|
||||
case DISPLAYLIST_RGUI_THEME_PRESETS:
|
||||
info->type_default = FILE_TYPE_RGUI_THEME_PRESET;
|
||||
info->exts = strdup("cfg");
|
||||
info->exts = strldup("cfg", sizeof("cfg"));
|
||||
break;
|
||||
case DISPLAYLIST_STREAM_CONFIG_FILES:
|
||||
info->type_default = FILE_TYPE_STREAM_CONFIG;
|
||||
info->exts = strdup("cfg");
|
||||
info->exts = strldup("cfg", sizeof("cfg"));
|
||||
break;
|
||||
case DISPLAYLIST_RECORD_CONFIG_FILES:
|
||||
info->type_default = FILE_TYPE_RECORD_CONFIG;
|
||||
info->exts = strdup("cfg");
|
||||
info->exts = strldup("cfg", sizeof("cfg"));
|
||||
break;
|
||||
case DISPLAYLIST_OVERLAYS:
|
||||
info->type_default = FILE_TYPE_OVERLAY;
|
||||
info->exts = strdup("cfg");
|
||||
info->exts = strldup("cfg", sizeof("cfg"));
|
||||
break;
|
||||
case DISPLAYLIST_FONTS:
|
||||
info->type_default = FILE_TYPE_FONT;
|
||||
info->exts = strdup("ttf");
|
||||
info->exts = strldup("ttf", sizeof("ttf"));
|
||||
break;
|
||||
case DISPLAYLIST_VIDEO_FONTS:
|
||||
info->type_default = FILE_TYPE_VIDEO_FONT;
|
||||
info->exts = strdup("ttf");
|
||||
info->exts = strldup("ttf", sizeof("ttf"));
|
||||
break;
|
||||
case DISPLAYLIST_AUDIO_FILTERS:
|
||||
info->type_default = FILE_TYPE_AUDIOFILTER;
|
||||
info->exts = strdup("dsp");
|
||||
info->exts = strldup("dsp", sizeof("dsp"));
|
||||
break;
|
||||
case DISPLAYLIST_CHEAT_FILES:
|
||||
info->type_default = FILE_TYPE_CHEAT;
|
||||
info->exts = strdup("cht");
|
||||
info->exts = strldup("cht", sizeof("cht"));
|
||||
break;
|
||||
case DISPLAYLIST_MANUAL_CONTENT_SCAN_DAT_FILES:
|
||||
info->type_default = FILE_TYPE_MANUAL_SCAN_DAT;
|
||||
info->exts = strdup("dat|xml");
|
||||
info->exts = strldup("dat|xml", sizeof("dat|xml"));
|
||||
break;
|
||||
case DISPLAYLIST_FILE_BROWSER_SELECT_SIDELOAD_CORE:
|
||||
{
|
||||
@ -14002,7 +14002,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
use_filebrowser = true;
|
||||
if (!string_is_empty(info->exts))
|
||||
free(info->exts);
|
||||
info->exts = strdup("lay|zip");
|
||||
info->exts = strldup("lay|zip", sizeof("lay|zip"));
|
||||
break;
|
||||
#endif
|
||||
case DISPLAYLIST_CONTENT_HISTORY:
|
||||
@ -14012,7 +14012,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
use_filebrowser = true;
|
||||
if (!string_is_empty(info->exts))
|
||||
free(info->exts);
|
||||
info->exts = strdup("lpl");
|
||||
info->exts = strldup("lpl", sizeof("lpl"));
|
||||
break;
|
||||
case DISPLAYLIST_DATABASE_PLAYLISTS:
|
||||
case DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL:
|
||||
|
@ -2253,7 +2253,7 @@ static bool menu_driver_displaylist_push_internal(
|
||||
if (!string_is_empty(info->label))
|
||||
free(info->label);
|
||||
|
||||
info->exts = strdup("lpl");
|
||||
info->exts = strldup("lpl", sizeof("lpl"));
|
||||
info->label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB));
|
||||
|
||||
@ -2271,7 +2271,7 @@ static bool menu_driver_displaylist_push_internal(
|
||||
if (!string_is_empty(info->label))
|
||||
free(info->label);
|
||||
|
||||
info->exts = strdup("lpl");
|
||||
info->exts = strldup("lpl", sizeof("lpl"));
|
||||
info->label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB));
|
||||
|
||||
@ -2289,7 +2289,7 @@ static bool menu_driver_displaylist_push_internal(
|
||||
if (!string_is_empty(info->label))
|
||||
free(info->label);
|
||||
|
||||
info->exts = strdup("lpl");
|
||||
info->exts = strldup("lpl", sizeof("lpl"));
|
||||
info->label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB));
|
||||
|
||||
@ -2322,7 +2322,7 @@ static bool menu_driver_displaylist_push_internal(
|
||||
if (!string_is_empty(info->label))
|
||||
free(info->label);
|
||||
|
||||
info->exts = strdup("lpl");
|
||||
info->exts = strldup("lpl", sizeof("lpl"));
|
||||
info->label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB));
|
||||
|
||||
|
@ -1347,7 +1347,7 @@ static void content_load_init_wrap(
|
||||
int *argc, char **argv)
|
||||
{
|
||||
*argc = 0;
|
||||
argv[(*argc)++] = strdup("retroarch");
|
||||
argv[(*argc)++] = strldup("retroarch", sizeof("retroarch"));
|
||||
|
||||
if (args->content_path)
|
||||
{
|
||||
@ -1359,38 +1359,38 @@ static void content_load_init_wrap(
|
||||
{
|
||||
RARCH_LOG("[Core]: %s\n",
|
||||
msg_hash_to_str(MSG_NO_CONTENT_STARTING_DUMMY_CORE));
|
||||
argv[(*argc)++] = strdup("--menu");
|
||||
argv[(*argc)++] = strldup("--menu", sizeof("--menu"));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (args->sram_path)
|
||||
{
|
||||
argv[(*argc)++] = strdup("-s");
|
||||
argv[(*argc)++] = strldup("-s", sizeof("-s"));
|
||||
argv[(*argc)++] = strdup(args->sram_path);
|
||||
}
|
||||
|
||||
if (args->state_path)
|
||||
{
|
||||
argv[(*argc)++] = strdup("-S");
|
||||
argv[(*argc)++] = strldup("-S", sizeof("-S"));
|
||||
argv[(*argc)++] = strdup(args->state_path);
|
||||
}
|
||||
|
||||
if (args->config_path)
|
||||
{
|
||||
argv[(*argc)++] = strdup("-c");
|
||||
argv[(*argc)++] = strldup("-c", sizeof("-c"));
|
||||
argv[(*argc)++] = strdup(args->config_path);
|
||||
}
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
if (args->libretro_path)
|
||||
{
|
||||
argv[(*argc)++] = strdup("-L");
|
||||
argv[(*argc)++] = strldup("-L", sizeof("-L"));
|
||||
argv[(*argc)++] = strdup(args->libretro_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (args->verbose)
|
||||
argv[(*argc)++] = strdup("-v");
|
||||
argv[(*argc)++] = strldup("-v", sizeof("-v"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,7 +125,7 @@ void task_file_load_handler(retro_task_t *task)
|
||||
|
||||
if (task_get_cancelled(task))
|
||||
{
|
||||
task_set_error(task, strdup("Task canceled."));
|
||||
task_set_error(task, strldup("Task canceled.", sizeof("Task canceled.")));
|
||||
task_set_finished(task, true);
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,8 @@ task_finished:
|
||||
free(tmp);
|
||||
|
||||
if (task_get_cancelled(task))
|
||||
task_set_error(task, strdup("Task cancelled."));
|
||||
task_set_error(task,
|
||||
strldup("Task cancelled.", sizeof("Task cancelled.")));
|
||||
else
|
||||
{
|
||||
data = (http_transfer_data_t*)malloc(sizeof(*data));
|
||||
@ -200,7 +201,8 @@ task_finished:
|
||||
task_set_data(task, data);
|
||||
|
||||
if (!task->mute)
|
||||
task_set_error(task, strdup("Download failed."));
|
||||
task_set_error(task, strldup("Download failed.",
|
||||
sizeof("Download failed.")));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -215,7 +217,8 @@ task_finished:
|
||||
|
||||
net_http_delete(http->handle);
|
||||
} else if (http->error)
|
||||
task_set_error(task, strdup("Internal error."));
|
||||
task_set_error(task, strldup("Internal error.",
|
||||
sizeof("Internal error.")));
|
||||
|
||||
free(http);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user