From 84692350055518a7eae1eb102788b06c0f1b46bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 19 Sep 2016 04:18:40 +0200 Subject: [PATCH] global->savefiles only accessed now from task_save.c --- paths.c | 36 +++---------------------------- tasks/task_save.c | 48 ++++++++++++++++++++++++++++++++++++++++++ tasks/tasks_internal.h | 6 ++++++ 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/paths.c b/paths.c index 6a1cc62726..adaebfd351 100644 --- a/paths.c +++ b/paths.c @@ -44,6 +44,7 @@ #include "retroarch.h" #include "runloop.h" #include "verbosity.h" +#include "tasks/tasks_internal.h" #define MENU_VALUE_NO_CORE 0x7d5472cbU @@ -343,7 +344,7 @@ static bool path_init_subsystem(void) } attr.i = mem->type; - string_list_append(global->savefiles, path, attr); + string_list_append((struct string_list*)savefile_ptr_get(), path, attr); } } @@ -368,36 +369,6 @@ static bool path_init_subsystem(void) return true; } -static void path_init_savefile_rtc(void) -{ - union string_list_elem_attr attr; - char savefile_name_rtc[PATH_MAX_LENGTH] = {0}; - global_t *global = global_get_ptr(); - - attr.i = RETRO_MEMORY_SAVE_RAM; - string_list_append(global->savefiles, global->name.savefile, attr); - - /* Infer .rtc save path from save ram path. */ - attr.i = RETRO_MEMORY_RTC; - fill_pathname(savefile_name_rtc, - global->name.savefile, - file_path_str(FILE_PATH_RTC_EXTENSION), - sizeof(savefile_name_rtc)); - string_list_append(global->savefiles, savefile_name_rtc, attr); -} - -void path_deinit_savefile(void) -{ - global_t *global = global_get_ptr(); - - if (!global) - return; - - if (global->savefiles) - string_list_free(global->savefiles); - global->savefiles = NULL; -} - void path_init_savefile(void) { global_t *global = global_get_ptr(); @@ -426,8 +397,7 @@ static void path_init_savefile_internal(void) path_deinit_savefile(); - global->savefiles = string_list_new(); - retro_assert(global->savefiles); + path_init_savefile_new(); if (!path_init_subsystem()) path_init_savefile_rtc(); diff --git a/tasks/task_save.c b/tasks/task_save.c index 081e2a83b0..68087be121 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -27,12 +27,14 @@ #include #include +#include #include #include #include #include #include "../core.h" +#include "../file_path_special.h" #include "../configuration.h" #include "../msg_hash.h" #include "../runloop.h" @@ -866,3 +868,49 @@ bool event_load_save_files(void) return true; } + +void path_init_savefile_rtc(void) +{ + union string_list_elem_attr attr; + char savefile_name_rtc[PATH_MAX_LENGTH] = {0}; + global_t *global = global_get_ptr(); + + attr.i = RETRO_MEMORY_SAVE_RAM; + string_list_append(global->savefiles, global->name.savefile, attr); + + /* Infer .rtc save path from save ram path. */ + attr.i = RETRO_MEMORY_RTC; + fill_pathname(savefile_name_rtc, + global->name.savefile, + file_path_str(FILE_PATH_RTC_EXTENSION), + sizeof(savefile_name_rtc)); + string_list_append(global->savefiles, savefile_name_rtc, attr); +} + +void path_deinit_savefile(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return; + + if (global->savefiles) + string_list_free(global->savefiles); + global->savefiles = NULL; +} + +void path_init_savefile_new(void) +{ + global_t *global = global_get_ptr(); + + global->savefiles = string_list_new(); + retro_assert(global->savefiles); +} + +void *savefile_ptr_get(void) +{ + global_t *global = global_get_ptr(); + if (!global) + return NULL; + return global->savefiles; +} diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 921a2eb650..f109a76bef 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -150,6 +150,12 @@ bool event_load_save_files(void); bool event_save_files(void); +void path_init_savefile_rtc(void); + +void *savefile_ptr_get(void); + +void path_init_savefile_new(void); + RETRO_END_DECLS #endif