mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
Turn g_config into static local variable
This commit is contained in:
parent
bb6ab7351b
commit
38d6cec9fd
@ -37,9 +37,56 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static settings_t *g_config;
|
|
||||||
struct defaults g_defaults;
|
struct defaults g_defaults;
|
||||||
|
|
||||||
|
static settings_t **config_get_ptr_double(void)
|
||||||
|
{
|
||||||
|
static settings_t *g_config;
|
||||||
|
return &g_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void config_free_ptr(void)
|
||||||
|
{
|
||||||
|
settings_t **settings = config_get_ptr_double();
|
||||||
|
*settings = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings_t *config_get_ptr(void)
|
||||||
|
{
|
||||||
|
settings_t **settings = config_get_ptr_double();
|
||||||
|
return *settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_free(void)
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
if (!settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
free(settings);
|
||||||
|
config_free_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool config_init(void)
|
||||||
|
{
|
||||||
|
settings_t **settings = config_get_ptr_double();
|
||||||
|
settings_t *config = (settings_t*)calloc(1, sizeof(settings_t));
|
||||||
|
|
||||||
|
if (!config)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*settings = config;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool config_realloc(void)
|
||||||
|
{
|
||||||
|
config_free();
|
||||||
|
return config_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config_get_default_audio:
|
* config_get_default_audio:
|
||||||
*
|
*
|
||||||
@ -2857,26 +2904,3 @@ bool config_save_file(const char *path)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_t *config_get_ptr(void)
|
|
||||||
{
|
|
||||||
return g_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
void config_free(void)
|
|
||||||
{
|
|
||||||
if (!g_config)
|
|
||||||
return;
|
|
||||||
|
|
||||||
free(g_config);
|
|
||||||
g_config = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
settings_t *config_init(void)
|
|
||||||
{
|
|
||||||
g_config = (settings_t*)calloc(1, sizeof(settings_t));
|
|
||||||
|
|
||||||
if (!g_config)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_config;
|
|
||||||
}
|
|
||||||
|
@ -543,7 +543,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user);
|
|||||||
**/
|
**/
|
||||||
bool config_save_file(const char *path);
|
bool config_save_file(const char *path);
|
||||||
|
|
||||||
settings_t *config_init(void);
|
bool config_realloc(void);
|
||||||
|
|
||||||
void config_free(void);
|
void config_free(void);
|
||||||
|
|
||||||
|
@ -1086,13 +1086,7 @@ static void main_init_state_config(void)
|
|||||||
|
|
||||||
void rarch_main_alloc(void)
|
void rarch_main_alloc(void)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
if (!config_realloc())
|
||||||
|
|
||||||
if (settings)
|
|
||||||
config_free();
|
|
||||||
settings = config_init();
|
|
||||||
|
|
||||||
if (!settings)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event_command(EVENT_CMD_HISTORY_DEINIT);
|
event_command(EVENT_CMD_HISTORY_DEINIT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user