task_content.c - small cleanups, initialize variables being passed

This commit is contained in:
libretroadmin 2025-07-21 05:59:09 +02:00
parent e24ca9da66
commit 4b77ad663a
1 changed files with 33 additions and 39 deletions

View File

@ -603,16 +603,16 @@ static bool content_file_list_set_info(
if (!string_is_empty(dir))
{
/* Remove any trailing slash */
char *last_slash = find_last_slash(dir);
char *last_slash = find_last_slash(dir);
if (last_slash && (last_slash[1] == '\0'))
*last_slash = '\0';
*last_slash = '\0';
if (!string_is_empty(dir))
file_info->dir = strdup(dir);
file_info->dir = strdup(dir);
}
if (!string_is_empty(name))
file_info->name = strdup(name);
file_info->name = strdup(name);
}
/* Assign retro_game_info pointers */
@ -660,24 +660,20 @@ static bool content_file_list_set_info(
* (see patch_content function) if soft patching has not been
* blocked by the user.
*
* Returns: true if successful, false on error.
* Returns: non-0 if successful, 0 on error.
**/
static bool content_file_load_into_memory(
static size_t content_file_load_into_memory(
content_information_ctx_t *content_ctx,
content_state_t *p_content,
const char *content_path,
bool content_compressed,
size_t idx,
enum rarch_content_type first_content_type,
uint8_t **data,
size_t *data_size)
uint8_t **data)
{
uint8_t *content_data = NULL;
int64_t content_size = 0;
*data = NULL;
*data_size = 0;
RARCH_LOG("[Content] %s: \"%s\".\n",
msg_hash_to_str(MSG_LOADING_CONTENT_FILE), content_path);
@ -687,16 +683,16 @@ static bool content_file_load_into_memory(
{
if (!file_archive_compressed_read(content_path,
(void**)&content_data, NULL, &content_size))
return false;
return 0;
}
else
#endif
if (!filestream_read_file(content_path,
(void**)&content_data, &content_size))
return false;
return 0;
if (content_size < 0)
return false;
return 0;
/* First content file is significant: attempt to do
* soft patching, CRC checking, etc. */
@ -752,9 +748,8 @@ static bool content_file_load_into_memory(
}
*data = content_data;
*data_size = (size_t)content_size;
return true;
return (size_t)content_size;
}
#ifdef HAVE_COMPRESSION
@ -818,9 +813,6 @@ static void content_file_get_path(
bool path_is_inside_archive;
const char *content_path = content->elems[idx].data;
*path = NULL;
*path_is_compressed = false;
if (string_is_empty(content_path))
return;
@ -912,7 +904,7 @@ static void content_file_apply_overrides(
content->elems[idx].attr.i |= BLCK_NEED_FULLPATH;
if (required)
content->elems[idx].attr.i |= BLCK_REQUIRED;
if ((persistent || override->persistent_data))
if (persistent || override->persistent_data)
content->elems[idx].attr.i |= BLCK_PERSISTENT;
}
}
@ -983,10 +975,12 @@ static bool content_file_load(
/* Doesn't need fullpath? */
if (!((content->elems[i].attr.i & BLCK_NEED_FULLPATH) != 0))
{
if (!content_file_load_into_memory(
content_data = NULL;
content_size = 0;
if ((content_size = content_file_load_into_memory(
content_ctx, p_content, content_path,
content_compressed, i, first_content_type,
&content_data, &content_size))
&content_data)) == 0)
{
char msg[PATH_MAX_LENGTH];
snprintf(msg, sizeof(msg), "%s \"%s\"\n",
@ -2322,14 +2316,14 @@ bool task_push_load_contentless_core_from_menu(
if (string_is_empty(core_path))
return false;
content_ctx.flags = 0;
content_ctx.flags = 0;
if (check_firmware_before_loading)
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING;
if (runloop_st->missing_bios)
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING;
if (!string_is_empty(path_dir_system))
content_ctx.directory_system = strdup(path_dir_system);
content_ctx.directory_system = strdup(path_dir_system);
/* Set core path */
path_set(RARCH_PATH_CORE, core_path);
@ -2338,7 +2332,7 @@ bool task_push_load_contentless_core_from_menu(
path_clear(RARCH_PATH_CONTENT);
#if defined(HAVE_DYNAMIC)
content_info.environ_get = menu_content_environment_get;
content_info.environ_get = menu_content_environment_get;
/* Load core */
command_event(CMD_EVENT_LOAD_CORE, NULL);
@ -2648,17 +2642,17 @@ static bool task_load_content_internal_wrap(
bool load_from_companion_ui)
{
/* Load content */
if (!task_load_content_internal(content_info, true, false,
if (task_load_content_internal(content_info, true, false,
load_from_companion_ui))
goto error;
{
#ifdef HAVE_MENU
/* Push Quick Menu onto menu stack */
if (type != CORE_TYPE_DUMMY)
menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL);
/* Push Quick Menu onto menu stack */
if (type != CORE_TYPE_DUMMY)
menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL);
#endif
return true;
return true;
}
error:
#ifdef HAVE_MENU
retroarch_menu_running();
#endif
@ -3002,11 +2996,11 @@ void content_deinit(void)
content_file_override_free(p_content);
content_file_list_free(p_content->content_list);
p_content->content_list = NULL;
p_content->rom_crc = 0;
p_content->flags &= ~(CONTENT_ST_FLAG_PENDING_ROM_CRC
| CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT
| CONTENT_ST_FLAG_IS_INITED);
p_content->content_list = NULL;
p_content->rom_crc = 0;
p_content->flags &= ~(CONTENT_ST_FLAG_PENDING_ROM_CRC
| CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT
| CONTENT_ST_FLAG_IS_INITED);
}
/* Set environment variables before a subsystem load */