mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
Put g_extern on heap
This commit is contained in:
parent
dc45cafa32
commit
f1fe7559bc
34
retroarch.c
34
retroarch.c
@ -1717,7 +1717,7 @@ void rarch_main_state_new(void)
|
|||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
main_clear_state(global->main_is_init);
|
main_clear_state(global ? global->main_is_init: false);
|
||||||
rarch_main_command(RARCH_CMD_MSG_QUEUE_INIT);
|
rarch_main_command(RARCH_CMD_MSG_QUEUE_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2385,6 +2385,9 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_CHEATS_DEINIT:
|
case RARCH_CMD_CHEATS_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->cheat)
|
if (global->cheat)
|
||||||
cheat_manager_free(global->cheat);
|
cheat_manager_free(global->cheat);
|
||||||
global->cheat = NULL;
|
global->cheat = NULL;
|
||||||
@ -2400,6 +2403,8 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
init_remapping();
|
init_remapping();
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_REWIND_DEINIT:
|
case RARCH_CMD_REWIND_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
#ifdef HAVE_NETPLAY
|
#ifdef HAVE_NETPLAY
|
||||||
if (driver->netplay_data)
|
if (driver->netplay_data)
|
||||||
return false;
|
return false;
|
||||||
@ -2501,6 +2506,9 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_DSP_FILTER_DEINIT:
|
case RARCH_CMD_DSP_FILTER_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->audio_data.dsp)
|
if (global->audio_data.dsp)
|
||||||
rarch_dsp_filter_free(global->audio_data.dsp);
|
rarch_dsp_filter_free(global->audio_data.dsp);
|
||||||
global->audio_data.dsp = NULL;
|
global->audio_data.dsp = NULL;
|
||||||
@ -2517,6 +2525,9 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
settings->audio.dsp_plugin);
|
settings->audio.dsp_plugin);
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_GPU_RECORD_DEINIT:
|
case RARCH_CMD_GPU_RECORD_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->record.gpu_buffer)
|
if (global->record.gpu_buffer)
|
||||||
free(global->record.gpu_buffer);
|
free(global->record.gpu_buffer);
|
||||||
global->record.gpu_buffer = NULL;
|
global->record.gpu_buffer = NULL;
|
||||||
@ -2545,6 +2556,9 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
settings->content_history_size);
|
settings->content_history_size);
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_CORE_INFO_DEINIT:
|
case RARCH_CMD_CORE_INFO_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->core_info)
|
if (global->core_info)
|
||||||
core_info_list_free(global->core_info);
|
core_info_list_free(global->core_info);
|
||||||
global->core_info = NULL;
|
global->core_info = NULL;
|
||||||
@ -2677,6 +2691,9 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_SHADER_DIR_DEINIT:
|
case RARCH_CMD_SHADER_DIR_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
dir_list_free(global->shader_dir.list);
|
dir_list_free(global->shader_dir.list);
|
||||||
global->shader_dir.list = NULL;
|
global->shader_dir.list = NULL;
|
||||||
global->shader_dir.ptr = 0;
|
global->shader_dir.ptr = 0;
|
||||||
@ -2707,6 +2724,9 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
save_files();
|
save_files();
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_SAVEFILES_DEINIT:
|
case RARCH_CMD_SAVEFILES_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->savefiles)
|
if (global->savefiles)
|
||||||
string_list_free(global->savefiles);
|
string_list_free(global->savefiles);
|
||||||
global->savefiles = NULL;
|
global->savefiles = NULL;
|
||||||
@ -2733,6 +2753,9 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
rarch_main_data_init_queues();
|
rarch_main_data_init_queues();
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_BSV_MOVIE_DEINIT:
|
case RARCH_CMD_BSV_MOVIE_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->bsv.movie)
|
if (global->bsv.movie)
|
||||||
bsv_movie_free(global->bsv.movie);
|
bsv_movie_free(global->bsv.movie);
|
||||||
global->bsv.movie = NULL;
|
global->bsv.movie = NULL;
|
||||||
@ -2806,16 +2829,25 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_TEMPORARY_CONTENT_DEINIT:
|
case RARCH_CMD_TEMPORARY_CONTENT_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->temporary_content)
|
if (global->temporary_content)
|
||||||
free_temporary_content();
|
free_temporary_content();
|
||||||
global->temporary_content = NULL;
|
global->temporary_content = NULL;
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT:
|
case RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->subsystem_fullpaths)
|
if (global->subsystem_fullpaths)
|
||||||
string_list_free(global->subsystem_fullpaths);
|
string_list_free(global->subsystem_fullpaths);
|
||||||
global->subsystem_fullpaths = NULL;
|
global->subsystem_fullpaths = NULL;
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_LOG_FILE_DEINIT:
|
case RARCH_CMD_LOG_FILE_DEINIT:
|
||||||
|
if (!global)
|
||||||
|
break;
|
||||||
|
|
||||||
if (global->log_file)
|
if (global->log_file)
|
||||||
fclose(global->log_file);
|
fclose(global->log_file);
|
||||||
global->log_file = NULL;
|
global->log_file = NULL;
|
||||||
|
25
runloop.c
25
runloop.c
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
static struct runloop *g_runloop;
|
static struct runloop *g_runloop;
|
||||||
|
|
||||||
struct global g_extern;
|
static struct global *g_extern;
|
||||||
|
|
||||||
/* Convenience macros. */
|
/* Convenience macros. */
|
||||||
#define check_oneshot_func(trigger_input) (check_is_oneshot(BIT64_GET(trigger_input, RARCH_FRAMEADVANCE), BIT64_GET(trigger_input, RARCH_REWIND)))
|
#define check_oneshot_func(trigger_input) (check_is_oneshot(BIT64_GET(trigger_input, RARCH_FRAMEADVANCE), BIT64_GET(trigger_input, RARCH_REWIND)))
|
||||||
@ -992,7 +992,7 @@ void rarch_main_msg_queue_init(void)
|
|||||||
|
|
||||||
global_t *global_get_ptr(void)
|
global_t *global_get_ptr(void)
|
||||||
{
|
{
|
||||||
return &g_extern;
|
return g_extern;
|
||||||
}
|
}
|
||||||
|
|
||||||
runloop_t *rarch_main_get_ptr(void)
|
runloop_t *rarch_main_get_ptr(void)
|
||||||
@ -1012,19 +1012,19 @@ static void rarch_main_state_deinit(void)
|
|||||||
|
|
||||||
static void rarch_main_global_deinit(void)
|
static void rarch_main_global_deinit(void)
|
||||||
{
|
{
|
||||||
|
global_t *global = NULL;
|
||||||
|
|
||||||
rarch_main_command(RARCH_CMD_TEMPORARY_CONTENT_DEINIT);
|
rarch_main_command(RARCH_CMD_TEMPORARY_CONTENT_DEINIT);
|
||||||
rarch_main_command(RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT);
|
rarch_main_command(RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT);
|
||||||
rarch_main_command(RARCH_CMD_RECORD_DEINIT);
|
rarch_main_command(RARCH_CMD_RECORD_DEINIT);
|
||||||
rarch_main_command(RARCH_CMD_LOG_FILE_DEINIT);
|
rarch_main_command(RARCH_CMD_LOG_FILE_DEINIT);
|
||||||
|
|
||||||
#if 0
|
global = global_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
|
|
||||||
if (!global)
|
if (!global)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
free(global);
|
free(global);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rarch_main_verbosity(void)
|
bool rarch_main_verbosity(void)
|
||||||
@ -1043,13 +1043,14 @@ FILE *rarch_main_log_file(void)
|
|||||||
return global->log_file;
|
return global->log_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rarch_main_global_init(void)
|
static global_t *rarch_main_global_init(void)
|
||||||
{
|
{
|
||||||
#if 0
|
global_t *global = (global_t*)calloc(1, sizeof(global_t));
|
||||||
g_extern = rarch_main_global_init();
|
|
||||||
#else
|
if (!global)
|
||||||
memset(&g_extern, 0, sizeof(g_extern));
|
return NULL;
|
||||||
#endif
|
|
||||||
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
static runloop_t *rarch_main_state_init(void)
|
static runloop_t *rarch_main_state_init(void)
|
||||||
@ -1068,7 +1069,7 @@ void rarch_main_clear_state(void)
|
|||||||
g_runloop = rarch_main_state_init();
|
g_runloop = rarch_main_state_init();
|
||||||
|
|
||||||
rarch_main_global_deinit();
|
rarch_main_global_deinit();
|
||||||
rarch_main_global_init();
|
g_extern = rarch_main_global_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rarch_main_is_idle(void)
|
bool rarch_main_is_idle(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user