Clean up more string variables on heap - move to stack
This commit is contained in:
parent
0c5611d10e
commit
216190b826
|
@ -305,7 +305,8 @@ struct libretro_vfs_implementation_file
|
||||||
libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||||
const char *path, unsigned mode, unsigned hints)
|
const char *path, unsigned mode, unsigned hints)
|
||||||
{
|
{
|
||||||
char *dirpath, *filename;
|
char dirpath[PATH_MAX_LENGTH];
|
||||||
|
char filename[PATH_MAX_LENGTH];
|
||||||
wchar_t *dirpath_wide;
|
wchar_t *dirpath_wide;
|
||||||
wchar_t *filename_wide;
|
wchar_t *filename_wide;
|
||||||
Platform::String^ filename_str;
|
Platform::String^ filename_str;
|
||||||
|
@ -322,20 +323,18 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||||
if (PATH_CHAR_IS_SLASH(path[strlen(path) - 1]))
|
if (PATH_CHAR_IS_SLASH(path[strlen(path) - 1]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dirpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
dirpath[0] = filename[0] = '\0';
|
||||||
fill_pathname_basedir(dirpath, path, PATH_MAX_LENGTH);
|
|
||||||
|
fill_pathname_basedir(dirpath, path, sizeof(dirpath));
|
||||||
dirpath_wide = utf8_to_utf16_string_alloc(dirpath);
|
dirpath_wide = utf8_to_utf16_string_alloc(dirpath);
|
||||||
windowsize_path(dirpath_wide);
|
windowsize_path(dirpath_wide);
|
||||||
dirpath_str = ref new Platform::String(dirpath_wide);
|
dirpath_str = ref new Platform::String(dirpath_wide);
|
||||||
free(dirpath_wide);
|
free(dirpath_wide);
|
||||||
free(dirpath);
|
|
||||||
|
|
||||||
filename = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
fill_pathname_base(filename, path, sizeof(filename));
|
||||||
fill_pathname_base(filename, path, PATH_MAX_LENGTH);
|
|
||||||
filename_wide = utf8_to_utf16_string_alloc(filename);
|
filename_wide = utf8_to_utf16_string_alloc(filename);
|
||||||
filename_str = ref new Platform::String(filename_wide);
|
filename_str = ref new Platform::String(filename_wide);
|
||||||
free(filename_wide);
|
free(filename_wide);
|
||||||
free(filename);
|
|
||||||
|
|
||||||
retro_assert(!dirpath_str->IsEmpty() && !filename_str->IsEmpty());
|
retro_assert(!dirpath_str->IsEmpty() && !filename_str->IsEmpty());
|
||||||
|
|
||||||
|
|
|
@ -3250,23 +3250,18 @@ static unsigned menu_displaylist_parse_cores(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
char *out_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char out_dir[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
out_dir[0] = '\0';
|
out_dir[0] = '\0';
|
||||||
|
|
||||||
fill_pathname_parent_dir(out_dir, path,
|
fill_pathname_parent_dir(out_dir, path, sizeof(out_dir));
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
if (string_is_empty(out_dir))
|
if (string_is_empty(out_dir))
|
||||||
{
|
|
||||||
menu_entries_prepend(info->list,
|
menu_entries_prepend(info->list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PARENT_DIRECTORY),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PARENT_DIRECTORY),
|
||||||
path,
|
path,
|
||||||
MENU_ENUM_LABEL_PARENT_DIRECTORY,
|
MENU_ENUM_LABEL_PARENT_DIRECTORY,
|
||||||
FILE_TYPE_PARENT_DIRECTORY, 0, 0);
|
FILE_TYPE_PARENT_DIRECTORY, 0, 0);
|
||||||
}
|
|
||||||
|
|
||||||
free(out_dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!str_list)
|
if (!str_list)
|
||||||
|
@ -3388,20 +3383,16 @@ static unsigned menu_displaylist_parse_cores(
|
||||||
|
|
||||||
if (type == FILE_TYPE_CORE)
|
if (type == FILE_TYPE_CORE)
|
||||||
{
|
{
|
||||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
char core_path[PATH_MAX_LENGTH];
|
||||||
char *core_path = (char*)malloc(path_size);
|
char display_name[PATH_MAX_LENGTH];
|
||||||
char *display_name = (char*)malloc(path_size);
|
|
||||||
core_path[0] =
|
core_path[0] =
|
||||||
display_name[0] = '\0';
|
display_name[0] = '\0';
|
||||||
|
|
||||||
fill_pathname_join(core_path, dir, path, path_size);
|
fill_pathname_join(core_path, dir, path, sizeof(core_path));
|
||||||
|
|
||||||
if (core_info_list_get_display_name(list,
|
if (core_info_list_get_display_name(list,
|
||||||
core_path, display_name, path_size))
|
core_path, display_name, sizeof(display_name)))
|
||||||
file_list_set_alt_at_offset(info->list, i, display_name);
|
file_list_set_alt_at_offset(info->list, i, display_name);
|
||||||
|
|
||||||
free(core_path);
|
|
||||||
free(display_name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info->need_sort = true;
|
info->need_sort = true;
|
||||||
|
|
|
@ -230,31 +230,27 @@ finish:
|
||||||
STRLEN_CONST(".index-dirs")
|
STRLEN_CONST(".index-dirs")
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
char *parent_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char parent_dir[PATH_MAX_LENGTH];
|
||||||
char *parent_dir_encoded = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char parent_dir_encoded[PATH_MAX_LENGTH];
|
||||||
file_transfer_t *transf = NULL;
|
file_transfer_t *transf = NULL;
|
||||||
|
|
||||||
parent_dir[0] = '\0';
|
parent_dir[0] = '\0';
|
||||||
parent_dir_encoded[0] = '\0';
|
parent_dir_encoded[0] = '\0';
|
||||||
|
|
||||||
fill_pathname_parent_dir(parent_dir,
|
fill_pathname_parent_dir(parent_dir,
|
||||||
state->path,
|
state->path, sizeof(parent_dir));
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
strlcat(parent_dir,
|
strlcat(parent_dir,
|
||||||
".index-dirs",
|
".index-dirs", sizeof(parent_dir));
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
transf = (file_transfer_t*)malloc(sizeof(*transf));
|
transf = (file_transfer_t*)malloc(sizeof(*transf));
|
||||||
|
|
||||||
transf->enum_idx = MSG_UNKNOWN;
|
transf->enum_idx = MSG_UNKNOWN;
|
||||||
strlcpy(transf->path, parent_dir, sizeof(transf->path));
|
strlcpy(transf->path, parent_dir, sizeof(transf->path));
|
||||||
|
|
||||||
net_http_urlencode_full(parent_dir_encoded, parent_dir, PATH_MAX_LENGTH * sizeof(char));
|
net_http_urlencode_full(parent_dir_encoded, parent_dir,
|
||||||
|
sizeof(parent_dir_encoded));
|
||||||
task_push_http_transfer_file(parent_dir_encoded, true,
|
task_push_http_transfer_file(parent_dir_encoded, true,
|
||||||
"index_dirs", cb_net_generic_subdir, transf);
|
"index_dirs", cb_net_generic_subdir, transf);
|
||||||
|
|
||||||
free(parent_dir);
|
|
||||||
free(parent_dir_encoded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
|
|
31
retroarch.c
31
retroarch.c
|
@ -6013,7 +6013,11 @@ bool menu_entries_append_enum(
|
||||||
free(list_info.fullpath);
|
free(list_info.fullpath);
|
||||||
|
|
||||||
file_list_free_actiondata(list, idx);
|
file_list_free_actiondata(list, idx);
|
||||||
cbs = (menu_file_list_cbs_t*)malloc(sizeof(menu_file_list_cbs_t));
|
cbs = (menu_file_list_cbs_t*)
|
||||||
|
malloc(sizeof(menu_file_list_cbs_t));
|
||||||
|
|
||||||
|
if (!cbs)
|
||||||
|
return false;
|
||||||
|
|
||||||
cbs->action_sublabel_cache[0] = '\0';
|
cbs->action_sublabel_cache[0] = '\0';
|
||||||
cbs->action_title_cache[0] = '\0';
|
cbs->action_title_cache[0] = '\0';
|
||||||
|
@ -6098,7 +6102,8 @@ void menu_entries_prepend(file_list_t *list,
|
||||||
free(list_info.fullpath);
|
free(list_info.fullpath);
|
||||||
|
|
||||||
file_list_free_actiondata(list, idx);
|
file_list_free_actiondata(list, idx);
|
||||||
cbs = (menu_file_list_cbs_t*)malloc(sizeof(menu_file_list_cbs_t));
|
cbs = (menu_file_list_cbs_t*)
|
||||||
|
malloc(sizeof(menu_file_list_cbs_t));
|
||||||
|
|
||||||
if (!cbs)
|
if (!cbs)
|
||||||
return;
|
return;
|
||||||
|
@ -37051,23 +37056,18 @@ void retroarch_menu_running_finished(bool quit)
|
||||||
**/
|
**/
|
||||||
static bool rarch_game_specific_options(char **output)
|
static bool rarch_game_specific_options(char **output)
|
||||||
{
|
{
|
||||||
size_t game_path_size = PATH_MAX_LENGTH * sizeof(char);
|
char game_path[PATH_MAX_LENGTH];
|
||||||
char *game_path = (char*)malloc(game_path_size);
|
|
||||||
|
|
||||||
game_path[0] ='\0';
|
game_path[0] ='\0';
|
||||||
|
|
||||||
if (!retroarch_validate_game_options(game_path,
|
if (!retroarch_validate_game_options(game_path,
|
||||||
game_path_size, false) || !path_is_valid(game_path))
|
sizeof(game_path), false) || !path_is_valid(game_path))
|
||||||
{
|
|
||||||
free(game_path);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
RARCH_LOG("%s %s\n",
|
RARCH_LOG("%s %s\n",
|
||||||
msg_hash_to_str(MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT),
|
msg_hash_to_str(MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT),
|
||||||
game_path);
|
game_path);
|
||||||
*output = strdup(game_path);
|
*output = strdup(game_path);
|
||||||
free(game_path);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37642,8 +37642,7 @@ static bool retroarch_load_shader_preset_internal(
|
||||||
const char *special_name)
|
const char *special_name)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char *shader_path = (char*)
|
char shader_path[PATH_MAX_LENGTH];
|
||||||
malloc(PATH_MAX_LENGTH);
|
|
||||||
|
|
||||||
static enum rarch_shader_type types[] =
|
static enum rarch_shader_type types[] =
|
||||||
{
|
{
|
||||||
|
@ -37663,16 +37662,17 @@ static bool retroarch_load_shader_preset_internal(
|
||||||
shader_directory, core_name,
|
shader_directory, core_name,
|
||||||
special_name,
|
special_name,
|
||||||
video_shader_get_preset_extension(types[i]),
|
video_shader_get_preset_extension(types[i]),
|
||||||
PATH_MAX_LENGTH);
|
sizeof(shader_path));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (string_is_empty(special_name))
|
if (string_is_empty(special_name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fill_pathname_join(shader_path, shader_directory, special_name, PATH_MAX_LENGTH);
|
fill_pathname_join(shader_path, shader_directory,
|
||||||
|
special_name, sizeof(shader_path));
|
||||||
strlcat(shader_path,
|
strlcat(shader_path,
|
||||||
video_shader_get_preset_extension(types[i]),
|
video_shader_get_preset_extension(types[i]),
|
||||||
PATH_MAX_LENGTH);
|
sizeof(shader_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!path_is_valid(shader_path))
|
if (!path_is_valid(shader_path))
|
||||||
|
@ -37682,12 +37682,9 @@ static bool retroarch_load_shader_preset_internal(
|
||||||
RARCH_LOG("[Shaders]: Specific shader preset found at %s.\n",
|
RARCH_LOG("[Shaders]: Specific shader preset found at %s.\n",
|
||||||
shader_path);
|
shader_path);
|
||||||
retroarch_set_runtime_shader_preset(p_rarch, shader_path);
|
retroarch_set_runtime_shader_preset(p_rarch, shader_path);
|
||||||
|
|
||||||
free(shader_path);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(shader_path);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -978,7 +978,7 @@ static bool content_file_load(
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_pathname_join(new_path, new_basedir,
|
fill_pathname_join(new_path, new_basedir,
|
||||||
path_basename(path), new_path_size);
|
path_basename(path), sizeof(new_path));
|
||||||
|
|
||||||
/* TODO: This may fail on very large files...
|
/* TODO: This may fail on very large files...
|
||||||
* but copying large files is not a good idea anyway */
|
* but copying large files is not a good idea anyway */
|
||||||
|
|
|
@ -250,60 +250,48 @@ error:
|
||||||
|
|
||||||
static int task_database_cue_get_serial(const char *name, char* serial)
|
static int task_database_cue_get_serial(const char *name, char* serial)
|
||||||
{
|
{
|
||||||
char *track_path = (char*)malloc(PATH_MAX_LENGTH
|
char track_path[PATH_MAX_LENGTH];
|
||||||
* sizeof(char));
|
|
||||||
int ret = 0;
|
|
||||||
uint64_t offset = 0;
|
uint64_t offset = 0;
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
track_path[0] = '\0';
|
track_path[0] = '\0';
|
||||||
|
|
||||||
rv = cue_find_track(name, true, &offset, &size, track_path, PATH_MAX_LENGTH);
|
rv = cue_find_track(name, true, &offset, &size, track_path, sizeof(track_path));
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
RARCH_LOG("%s: %s\n",
|
RARCH_LOG("%s: %s\n",
|
||||||
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
free(track_path);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
||||||
|
|
||||||
ret = intfstream_file_get_serial(track_path, offset, size, serial);
|
return intfstream_file_get_serial(track_path, offset, size, serial);
|
||||||
free(track_path);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int task_database_gdi_get_serial(const char *name, char* serial)
|
static int task_database_gdi_get_serial(const char *name, char* serial)
|
||||||
{
|
{
|
||||||
char *track_path = (char*)malloc(PATH_MAX_LENGTH
|
char track_path[PATH_MAX_LENGTH];
|
||||||
* sizeof(char));
|
|
||||||
int ret = 0;
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
track_path[0] = '\0';
|
track_path[0] = '\0';
|
||||||
|
|
||||||
rv = gdi_find_track(name, true, track_path, PATH_MAX_LENGTH);
|
rv = gdi_find_track(name, true, track_path, sizeof(track_path));
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
RARCH_LOG("%s: %s\n",
|
RARCH_LOG("%s: %s\n",
|
||||||
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
free(track_path);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
||||||
|
|
||||||
ret = intfstream_file_get_serial(track_path, 0, SIZE_MAX, serial);
|
return intfstream_file_get_serial(track_path, 0, SIZE_MAX, serial);
|
||||||
free(track_path);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int task_database_chd_get_serial(const char *name, char* serial)
|
static int task_database_chd_get_serial(const char *name, char* serial)
|
||||||
|
@ -384,7 +372,7 @@ error:
|
||||||
|
|
||||||
static int task_database_cue_get_crc(const char *name, uint32_t *crc)
|
static int task_database_cue_get_crc(const char *name, uint32_t *crc)
|
||||||
{
|
{
|
||||||
char *track_path = (char *)malloc(PATH_MAX_LENGTH);
|
char track_path[PATH_MAX_LENGTH];
|
||||||
uint64_t offset = 0;
|
uint64_t offset = 0;
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
@ -392,14 +380,13 @@ static int task_database_cue_get_crc(const char *name, uint32_t *crc)
|
||||||
track_path[0] = '\0';
|
track_path[0] = '\0';
|
||||||
|
|
||||||
rv = cue_find_track(name, false, &offset, &size,
|
rv = cue_find_track(name, false, &offset, &size,
|
||||||
track_path, PATH_MAX_LENGTH);
|
track_path, sizeof(track_path));
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
RARCH_LOG("%s: %s\n",
|
RARCH_LOG("%s: %s\n",
|
||||||
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
free(track_path);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,24 +399,22 @@ static int task_database_cue_get_crc(const char *name, uint32_t *crc)
|
||||||
{
|
{
|
||||||
RARCH_LOG("CUE '%s' crc: %x\n", name, *crc);
|
RARCH_LOG("CUE '%s' crc: %x\n", name, *crc);
|
||||||
}
|
}
|
||||||
free(track_path);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int task_database_gdi_get_crc(const char *name, uint32_t *crc)
|
static int task_database_gdi_get_crc(const char *name, uint32_t *crc)
|
||||||
{
|
{
|
||||||
char *track_path = (char *)malloc(PATH_MAX_LENGTH);
|
char track_path[PATH_MAX_LENGTH];
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
track_path[0] = '\0';
|
track_path[0] = '\0';
|
||||||
|
|
||||||
rv = gdi_find_track(name, true, track_path, PATH_MAX_LENGTH);
|
rv = gdi_find_track(name, true, track_path, sizeof(track_path));
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
free(track_path);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +427,6 @@ static int task_database_gdi_get_crc(const char *name, uint32_t *crc)
|
||||||
{
|
{
|
||||||
RARCH_LOG("GDI '%s' crc: %x\n", name, *crc);
|
RARCH_LOG("GDI '%s' crc: %x\n", name, *crc);
|
||||||
}
|
}
|
||||||
free(track_path);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,14 +458,16 @@ static void task_database_cue_prune(database_info_handle_t *db,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char *path = (char *)malloc(PATH_MAX_LENGTH + 1);
|
char path[PATH_MAX_LENGTH];
|
||||||
intfstream_t *fd = intfstream_open_file(name,
|
intfstream_t *fd = intfstream_open_file(name,
|
||||||
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||||
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
goto end;
|
return;
|
||||||
|
|
||||||
while (cue_next_file(fd, name, path, PATH_MAX_LENGTH))
|
path[0] = '\0';
|
||||||
|
|
||||||
|
while (cue_next_file(fd, name, path, sizeof(path)))
|
||||||
{
|
{
|
||||||
for (i = db->list_ptr; i < db->list->size; ++i)
|
for (i = db->list_ptr; i < db->list->size; ++i)
|
||||||
{
|
{
|
||||||
|
@ -495,26 +481,23 @@ static void task_database_cue_prune(database_info_handle_t *db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
intfstream_close(fd);
|
||||||
if (fd)
|
free(fd);
|
||||||
{
|
|
||||||
intfstream_close(fd);
|
|
||||||
free(fd);
|
|
||||||
}
|
|
||||||
free(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdi_prune(database_info_handle_t *db, const char *name)
|
static void gdi_prune(database_info_handle_t *db, const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char *path = (char *)malloc(PATH_MAX_LENGTH + 1);
|
char path[PATH_MAX_LENGTH];
|
||||||
intfstream_t *fd = intfstream_open_file(name,
|
intfstream_t *fd = intfstream_open_file(name,
|
||||||
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||||
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
goto end;
|
return;
|
||||||
|
|
||||||
while (gdi_next_file(fd, name, path, PATH_MAX_LENGTH))
|
path[0] = '\0';
|
||||||
|
|
||||||
|
while (gdi_next_file(fd, name, path, sizeof(path)))
|
||||||
{
|
{
|
||||||
for (i = db->list_ptr; i < db->list->size; ++i)
|
for (i = db->list_ptr; i < db->list->size; ++i)
|
||||||
{
|
{
|
||||||
|
@ -528,9 +511,7 @@ static void gdi_prune(database_info_handle_t *db, const char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
|
||||||
free(fd);
|
free(fd);
|
||||||
free(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum msg_file_type extension_to_file_type(const char *ext)
|
static enum msg_file_type extension_to_file_type(const char *ext)
|
||||||
|
@ -665,14 +646,12 @@ static int database_info_list_iterate_end_no_match(
|
||||||
|
|
||||||
for (i = 0; i < archive_list->size; i++)
|
for (i = 0; i < archive_list->size; i++)
|
||||||
{
|
{
|
||||||
char *new_path = (char*)malloc(
|
char new_path[PATH_MAX_LENGTH];
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
|
||||||
size_t path_len = strlen(path);
|
size_t path_len = strlen(path);
|
||||||
|
|
||||||
new_path[0] = '\0';
|
new_path[0] = '\0';
|
||||||
|
|
||||||
strlcpy(new_path, path, path_size);
|
strlcpy(new_path, path, sizeof(new_path));
|
||||||
|
|
||||||
if (path_len + strlen(archive_list->elems[i].data)
|
if (path_len + strlen(archive_list->elems[i].data)
|
||||||
+ 1 < PATH_MAX_LENGTH)
|
+ 1 < PATH_MAX_LENGTH)
|
||||||
|
@ -680,13 +659,11 @@ static int database_info_list_iterate_end_no_match(
|
||||||
new_path[path_len] = '#';
|
new_path[path_len] = '#';
|
||||||
strlcpy(new_path + path_len + 1,
|
strlcpy(new_path + path_len + 1,
|
||||||
archive_list->elems[i].data,
|
archive_list->elems[i].data,
|
||||||
path_size - path_len);
|
sizeof(new_path) - path_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_append(db->list, new_path,
|
string_list_append(db->list, new_path,
|
||||||
archive_list->elems[i].attr);
|
archive_list->elems[i].attr);
|
||||||
|
|
||||||
free(new_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_free(archive_list);
|
string_list_free(archive_list);
|
||||||
|
@ -731,10 +708,11 @@ static int database_info_list_iterate_found_match(
|
||||||
const char *archive_name
|
const char *archive_name
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
char *db_crc = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char db_crc[PATH_MAX_LENGTH];
|
||||||
char *db_playlist_base_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char db_playlist_base_str[PATH_MAX_LENGTH];
|
||||||
char *db_playlist_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char db_playlist_path[PATH_MAX_LENGTH];
|
||||||
char *entry_path_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char entry_path_str[PATH_MAX_LENGTH];
|
||||||
|
char *hash = NULL;
|
||||||
playlist_t *playlist = NULL;
|
playlist_t *playlist = NULL;
|
||||||
const char *db_path =
|
const char *db_path =
|
||||||
database_info_get_current_name(db_state);
|
database_info_get_current_name(db_state);
|
||||||
|
@ -742,7 +720,6 @@ static int database_info_list_iterate_found_match(
|
||||||
database_info_get_current_element_name(db);
|
database_info_get_current_element_name(db);
|
||||||
database_info_t *db_info_entry =
|
database_info_t *db_info_entry =
|
||||||
&db_state->info->list[db_state->entry_index];
|
&db_state->info->list[db_state->entry_index];
|
||||||
char *hash;
|
|
||||||
|
|
||||||
db_crc[0] = '\0';
|
db_crc[0] = '\0';
|
||||||
db_playlist_path[0] = '\0';
|
db_playlist_path[0] = '\0';
|
||||||
|
@ -750,29 +727,25 @@ static int database_info_list_iterate_found_match(
|
||||||
entry_path_str[0] = '\0';
|
entry_path_str[0] = '\0';
|
||||||
|
|
||||||
fill_short_pathname_representation_noext(db_playlist_base_str,
|
fill_short_pathname_representation_noext(db_playlist_base_str,
|
||||||
db_path, PATH_MAX_LENGTH * sizeof(char));
|
db_path, sizeof(db_playlist_base_str));
|
||||||
|
|
||||||
strlcat(db_playlist_base_str,
|
strlcat(db_playlist_base_str, ".lpl", sizeof(db_playlist_base_str));
|
||||||
".lpl",
|
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
if (!string_is_empty(_db->playlist_directory))
|
if (!string_is_empty(_db->playlist_directory))
|
||||||
fill_pathname_join(db_playlist_path, _db->playlist_directory,
|
fill_pathname_join(db_playlist_path, _db->playlist_directory,
|
||||||
db_playlist_base_str, PATH_MAX_LENGTH * sizeof(char));
|
db_playlist_base_str, sizeof(db_playlist_path));
|
||||||
|
|
||||||
playlist_config_set_path(&_db->playlist_config, db_playlist_path);
|
playlist_config_set_path(&_db->playlist_config, db_playlist_path);
|
||||||
playlist = playlist_init(&_db->playlist_config);
|
playlist = playlist_init(&_db->playlist_config);
|
||||||
|
|
||||||
snprintf(db_crc, PATH_MAX_LENGTH * sizeof(char),
|
snprintf(db_crc, sizeof(db_crc), "%08X|crc", db_info_entry->crc32);
|
||||||
"%08X|crc", db_info_entry->crc32);
|
|
||||||
|
|
||||||
if (entry_path)
|
if (entry_path)
|
||||||
strlcpy(entry_path_str, entry_path, PATH_MAX_LENGTH * sizeof(char));
|
strlcpy(entry_path_str, entry_path, sizeof(entry_path_str));
|
||||||
|
|
||||||
if (!string_is_empty(archive_name))
|
if (!string_is_empty(archive_name))
|
||||||
fill_pathname_join_delim(entry_path_str,
|
fill_pathname_join_delim(entry_path_str,
|
||||||
entry_path_str, archive_name,
|
entry_path_str, archive_name, '#', sizeof(entry_path_str));
|
||||||
'#', PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
if (core_info_database_match_archive_member(
|
if (core_info_database_match_archive_member(
|
||||||
db_state->list->elems[db_state->list_index].data) &&
|
db_state->list->elems[db_state->list_index].data) &&
|
||||||
|
@ -841,11 +814,6 @@ static int database_info_list_iterate_found_match(
|
||||||
db_state->crc = 0;
|
db_state->crc = 0;
|
||||||
db_state->archive_crc = 0;
|
db_state->archive_crc = 0;
|
||||||
|
|
||||||
free(entry_path_str);
|
|
||||||
free(db_playlist_path);
|
|
||||||
free(db_playlist_base_str);
|
|
||||||
free(db_crc);
|
|
||||||
|
|
||||||
/* Move database to start since we are likely to match against it
|
/* Move database to start since we are likely to match against it
|
||||||
again */
|
again */
|
||||||
if (db_state->list_index != 0)
|
if (db_state->list_index != 0)
|
||||||
|
@ -979,7 +947,7 @@ static int task_database_iterate_playlist_lutro(
|
||||||
database_info_handle_t *db,
|
database_info_handle_t *db,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
char *db_playlist_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char db_playlist_path[PATH_MAX_LENGTH];
|
||||||
playlist_t *playlist = NULL;
|
playlist_t *playlist = NULL;
|
||||||
|
|
||||||
db_playlist_path[0] = '\0';
|
db_playlist_path[0] = '\0';
|
||||||
|
@ -987,24 +955,20 @@ static int task_database_iterate_playlist_lutro(
|
||||||
if (!string_is_empty(_db->playlist_directory))
|
if (!string_is_empty(_db->playlist_directory))
|
||||||
fill_pathname_join(db_playlist_path,
|
fill_pathname_join(db_playlist_path,
|
||||||
_db->playlist_directory,
|
_db->playlist_directory,
|
||||||
"Lutro.lpl",
|
"Lutro.lpl", sizeof(db_playlist_path));
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
playlist_config_set_path(&_db->playlist_config, db_playlist_path);
|
playlist_config_set_path(&_db->playlist_config, db_playlist_path);
|
||||||
playlist = playlist_init(&_db->playlist_config);
|
playlist = playlist_init(&_db->playlist_config);
|
||||||
|
|
||||||
free(db_playlist_path);
|
|
||||||
|
|
||||||
if (!playlist_entry_exists(playlist, path))
|
if (!playlist_entry_exists(playlist, path))
|
||||||
{
|
{
|
||||||
struct playlist_entry entry;
|
struct playlist_entry entry;
|
||||||
char *game_title = (char*)
|
char game_title[PATH_MAX_LENGTH];
|
||||||
malloc(PATH_MAX_LENGTH * sizeof(char));
|
|
||||||
|
|
||||||
game_title[0] = '\0';
|
game_title[0] = '\0';
|
||||||
|
|
||||||
fill_short_pathname_representation_noext(game_title,
|
fill_short_pathname_representation_noext(game_title,
|
||||||
path, PATH_MAX_LENGTH * sizeof(char));
|
path, sizeof(game_title));
|
||||||
|
|
||||||
/* the push function reads our entry as const,
|
/* the push function reads our entry as const,
|
||||||
* so these casts are safe */
|
* so these casts are safe */
|
||||||
|
@ -1028,8 +992,6 @@ static int task_database_iterate_playlist_lutro(
|
||||||
entry.last_played_second = 0;
|
entry.last_played_second = 0;
|
||||||
|
|
||||||
playlist_push(playlist, &entry);
|
playlist_push(playlist, &entry);
|
||||||
|
|
||||||
free(game_title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist_write_file(playlist);
|
playlist_write_file(playlist);
|
||||||
|
|
Loading…
Reference in New Issue