Create rarch_main_global_init/rarch_main_global_deinit

This commit is contained in:
twinaphex 2015-03-21 01:53:14 +01:00
parent 80840cac0c
commit 533c5c0eb1
2 changed files with 29 additions and 13 deletions

View File

@ -1638,24 +1638,11 @@ static void free_temporary_content(void)
/* main_clear_state_extern:
*
* Clears all external state.
*
* XXX This memset is really dangerous.
*
* (a) it can leak memory because the pointers
* in g_extern aren't freed.
* (b) it can zero pointers that the rest of
* the code will look at.
*/
static void main_clear_state_extern(void)
{
rarch_main_command(RARCH_CMD_TEMPORARY_CONTENT_DEINIT);
rarch_main_command(RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT);
rarch_main_command(RARCH_CMD_RECORD_DEINIT);
rarch_main_command(RARCH_CMD_LOG_FILE_DEINIT);
rarch_main_command(RARCH_CMD_HISTORY_DEINIT);
memset(&g_extern, 0, sizeof(g_extern));
rarch_main_clear_state();
rarch_main_data_clear_state();
}

View File

@ -982,6 +982,32 @@ static void rarch_main_state_deinit(void)
free(runloop);
}
static void rarch_main_global_deinit(void)
{
rarch_main_command(RARCH_CMD_TEMPORARY_CONTENT_DEINIT);
rarch_main_command(RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT);
rarch_main_command(RARCH_CMD_RECORD_DEINIT);
rarch_main_command(RARCH_CMD_LOG_FILE_DEINIT);
#if 0
global_t *global = &g_extern;
if (!global)
return;
free(global);
#endif
}
static void rarch_main_global_init(void)
{
#if 0
g_extern = rarch_main_global_init();
#else
memset(&g_extern, 0, sizeof(g_extern));
#endif
}
static runloop_t *rarch_main_state_init(void)
{
runloop_t *runloop = (runloop_t*)calloc(1, sizeof(runloop_t));
@ -996,6 +1022,9 @@ void rarch_main_clear_state(void)
{
rarch_main_state_deinit();
g_runloop = rarch_main_state_init();
rarch_main_global_deinit();
rarch_main_global_init();
}
bool rarch_main_is_idle(void)