mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 06:40:18 +00:00
Put g_driver on heap and make it a pointer
This commit is contained in:
parent
248d985ae6
commit
2a8f9fdfc0
37
driver.c
37
driver.c
@ -30,7 +30,38 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
static driver_t g_driver;
|
||||
static driver_t *g_driver;
|
||||
|
||||
void driver_free(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
if (!driver)
|
||||
return;
|
||||
|
||||
free(driver);
|
||||
}
|
||||
|
||||
static driver_t *driver_alloc(void)
|
||||
{
|
||||
driver_t *driver = (driver_t*)calloc(1, sizeof(driver_t));
|
||||
|
||||
if (!driver)
|
||||
return NULL;
|
||||
|
||||
return driver;
|
||||
}
|
||||
|
||||
void driver_clear_state(void)
|
||||
{
|
||||
driver_free();
|
||||
g_driver = driver_alloc();
|
||||
}
|
||||
|
||||
driver_t *driver_get_ptr(void)
|
||||
{
|
||||
return g_driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* find_driver_nonempty:
|
||||
@ -441,7 +472,3 @@ void uninit_drivers(int flags)
|
||||
driver->audio_data = NULL;
|
||||
}
|
||||
|
||||
driver_t *driver_get_ptr(void)
|
||||
{
|
||||
return &g_driver;
|
||||
}
|
||||
|
4
driver.h
4
driver.h
@ -394,6 +394,10 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info);
|
||||
int find_driver_index(const char * label, const char *drv);
|
||||
|
||||
driver_t *driver_get_ptr(void);
|
||||
|
||||
void driver_free(void);
|
||||
|
||||
void driver_clear_state(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -121,6 +121,8 @@ void main_exit(args_type() args)
|
||||
|
||||
if (driver->frontend_ctx && driver->frontend_ctx->shutdown)
|
||||
driver->frontend_ctx->shutdown(false);
|
||||
|
||||
driver_free();
|
||||
}
|
||||
|
||||
static void check_defaults_dirs(void)
|
||||
|
@ -1009,6 +1009,7 @@ runloop_t *rarch_main_get_ptr(void)
|
||||
return g_runloop;
|
||||
}
|
||||
|
||||
|
||||
void rarch_main_state_deinit(void)
|
||||
{
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
@ -1074,6 +1075,8 @@ static runloop_t *rarch_main_state_init(void)
|
||||
|
||||
void rarch_main_clear_state(void)
|
||||
{
|
||||
driver_clear_state();
|
||||
|
||||
rarch_main_state_deinit();
|
||||
g_runloop = rarch_main_state_init();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user