From 8abb916f66a7a54428b5d40177f07d5eb7c45d77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 2 Aug 2014 17:42:01 +0200 Subject: [PATCH] Refactor content_history_init/deinit --- frontend/menu/menu_common.c | 15 +++++++-------- general.h | 2 ++ retroarch.c | 8 ++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index a69d9ad58b..a98336a617 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -216,9 +216,8 @@ bool load_menu_content(void) if (driver.menu) menu_update_libretro_info(driver.menu); - if (g_extern.history) - content_history_free(g_extern.history); - g_extern.history = content_history_init(g_settings.content_history_path, g_settings.game_history_size); + rarch_main_command(RARCH_CMD_HISTORY_DEINIT); + rarch_main_command(RARCH_CMD_HISTORY_INIT); if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_init) driver.menu_ctx->backend->shader_manager_init(driver.menu); @@ -264,7 +263,7 @@ void *menu_init(const void *data) if (menu_ctx && menu_ctx->backend && menu_ctx->backend->shader_manager_init) menu_ctx->backend->shader_manager_init(menu); - g_extern.history = content_history_init(g_settings.content_history_path, g_settings.game_history_size); + rarch_main_command(RARCH_CMD_HISTORY_INIT); menu->last_time = rarch_get_time_usec(); return menu; @@ -293,10 +292,10 @@ void menu_free(void *data) file_list_free(menu->menu_stack); file_list_free(menu->selection_buf); - if (g_extern.history) - content_history_free(g_extern.history); - g_extern.history = NULL; - core_info_list_free(menu->core_info); + rarch_main_command(RARCH_CMD_HISTORY_DEINIT); + + if (menu->core_info) + core_info_list_free(menu->core_info); if (menu->core_info_current) free(menu->core_info_current); diff --git a/general.h b/general.h index 80ecb06d93..88b0f5e4fd 100644 --- a/general.h +++ b/general.h @@ -110,6 +110,8 @@ enum basic_event RARCH_CMD_DSP_FILTER_DEINIT, RARCH_CMD_RECORD_INIT, RARCH_CMD_RECORD_DEINIT, + RARCH_CMD_HISTORY_DEINIT, + RARCH_CMD_HISTORY_INIT, }; enum menu_enums diff --git a/retroarch.c b/retroarch.c index c3df953b17..7dd1b65f53 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3258,6 +3258,14 @@ void rarch_main_command(unsigned action) deinit_recording(); #endif break; + case RARCH_CMD_HISTORY_INIT: + g_extern.history = content_history_init(g_settings.content_history_path, g_settings.game_history_size); + break; + case RARCH_CMD_HISTORY_DEINIT: + if (g_extern.history) + content_history_free(g_extern.history); + g_extern.history = NULL; + break; } }