From 4d20460e6bdcadaa0b8fe227ef5d49981c2bd4aa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 7 May 2017 17:52:48 +0200 Subject: [PATCH] Cleanup task_save.c --- command.c | 5 +++-- paths.c | 5 ++++- tasks/task_save.c | 17 ++++++++--------- tasks/tasks_internal.h | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/command.c b/command.c index 715dc53d62..01aa047bee 100644 --- a/command.c +++ b/command.c @@ -2063,9 +2063,10 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_AUTOSAVE_INIT: command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL); #ifdef HAVE_THREADS - autosave_init(); -#endif + return autosave_init(); +#else break; +#endif case CMD_EVENT_AUTOSAVE_STATE: command_event_save_auto_state(); break; diff --git a/paths.c b/paths.c index c95219b1d1..3752c9193b 100644 --- a/paths.c +++ b/paths.c @@ -402,7 +402,10 @@ static void path_init_savefile_internal(void) path_init_savefile_new(); if (!path_init_subsystem()) - path_init_savefile_rtc(); + { + global_t *global = global_get_ptr(); + path_init_savefile_rtc(global->name.savefile); + } } diff --git a/tasks/task_save.c b/tasks/task_save.c index ecbbf4e79f..ab8c77cf8e 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -1063,8 +1063,8 @@ static void content_load_and_save_state_cb(void *task_data, static void task_push_load_and_save_state(const char *path, void *data, size_t size, bool load_to_backup_buffer, bool autosave) { - retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); - save_task_state_t *state = (save_task_state_t*)calloc(1, sizeof(*state)); + retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); + save_task_state_t *state = (save_task_state_t*)calloc(1, sizeof(*state)); settings_t *settings = config_get_ptr(); if (!task || !state) @@ -1202,9 +1202,9 @@ bool content_save_state(const char *path, bool save_to_disk, bool autosave) bool content_load_state(const char *path, bool load_to_backup_buffer, bool autoload) { - retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); - save_task_state_t *state = (save_task_state_t*)calloc(1, sizeof(*state)); - settings_t *settings = config_get_ptr(); + retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); + save_task_state_t *state = (save_task_state_t*)calloc(1, sizeof(*state)); + settings_t *settings = config_get_ptr(); if (!task || !state) goto error; @@ -1451,21 +1451,20 @@ bool event_load_save_files(void) return true; } -void path_init_savefile_rtc(void) +void path_init_savefile_rtc(const char *savefile_path) { union string_list_elem_attr attr; char savefile_name_rtc[PATH_MAX_LENGTH]; - global_t *global = global_get_ptr(); savefile_name_rtc[0] = '\0'; attr.i = RETRO_MEMORY_SAVE_RAM; - string_list_append(task_save_files, global->name.savefile, attr); + string_list_append(task_save_files, savefile_path, attr); /* Infer .rtc save path from save ram path. */ attr.i = RETRO_MEMORY_RTC; fill_pathname(savefile_name_rtc, - global->name.savefile, + savefile_path, file_path_str(FILE_PATH_RTC_EXTENSION), sizeof(savefile_name_rtc)); string_list_append(task_save_files, savefile_name_rtc, attr); diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 0d0153da30..4fe49bc630 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -213,7 +213,7 @@ bool event_load_save_files(void); bool event_save_files(void); -void path_init_savefile_rtc(void); +void path_init_savefile_rtc(const char *savefile_path); void *savefile_ptr_get(void);