mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 00:32:49 +00:00
Put g_config on heap
This commit is contained in:
parent
0724617abd
commit
80840cac0c
@ -31,7 +31,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
static settings_t g_config;
|
||||
static settings_t *g_config;
|
||||
struct global g_extern;
|
||||
struct defaults g_defaults;
|
||||
|
||||
@ -1068,6 +1068,7 @@ static bool config_load_file(const char *path, bool set_defaults)
|
||||
unsigned msg_color = 0;
|
||||
config_file_t *conf = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = &g_extern;
|
||||
|
||||
if (path)
|
||||
{
|
||||
@ -2148,5 +2149,24 @@ bool config_save_file(const char *path)
|
||||
|
||||
settings_t *config_get_ptr(void)
|
||||
{
|
||||
return &g_config;
|
||||
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;
|
||||
}
|
||||
|
@ -407,6 +407,10 @@ bool config_save_keybinds_file(const char *path);
|
||||
**/
|
||||
bool config_save_file(const char *path);
|
||||
|
||||
settings_t *config_init(void);
|
||||
|
||||
void config_free(void);
|
||||
|
||||
settings_t *config_get_ptr(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -124,7 +124,7 @@ typedef struct rarch_resolution
|
||||
|
||||
/* All run-time- / command line flag-related globals go here. */
|
||||
|
||||
struct global
|
||||
typedef struct global
|
||||
{
|
||||
bool verbosity;
|
||||
bool perfcnt_enable;
|
||||
@ -441,10 +441,10 @@ struct global
|
||||
char core_specific_config_path[PATH_MAX_LENGTH];
|
||||
|
||||
retro_keyboard_event_t frontend_key_event;
|
||||
};
|
||||
} global_t;
|
||||
|
||||
/* Public data structures. */
|
||||
extern struct global g_extern;
|
||||
extern global_t g_extern;
|
||||
extern struct defaults g_defaults;
|
||||
|
||||
/* Public functions. */
|
||||
|
@ -29,38 +29,38 @@
|
||||
#define CONFIG_GET_BOOL_BASE(conf, base, var, key) do { \
|
||||
bool tmp = false; \
|
||||
if (config_get_bool(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
base->var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_INT_BASE(conf, base, var, key) do { \
|
||||
int tmp = 0; \
|
||||
if (config_get_int(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
base->var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_UINT64_BASE(conf, base, var, key) do { \
|
||||
uint64_t tmp = 0; \
|
||||
if (config_get_int(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
base->var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_HEX_BASE(conf, base, var, key) do { \
|
||||
unsigned tmp = 0; \
|
||||
if (config_get_hex(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
base->var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_FLOAT_BASE(conf, base, var, key) do { \
|
||||
float tmp = 0.0f; \
|
||||
if (config_get_float(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
base->var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_STRING_BASE(conf, base, var, key) \
|
||||
config_get_array(conf, key, base.var, sizeof(base.var))
|
||||
config_get_array(conf, key, base->var, sizeof(base->var))
|
||||
|
||||
#define CONFIG_GET_PATH_BASE(conf, base, var, key) \
|
||||
config_get_path(conf, key, base.var, sizeof(base.var))
|
||||
config_get_path(conf, key, base->var, sizeof(base->var))
|
||||
|
||||
#define CONFIG_GET_BOOL(var, key) CONFIG_GET_BOOL_BASE(conf, g_config, var, key)
|
||||
#define CONFIG_GET_INT(var, key) CONFIG_GET_INT_BASE(conf, g_config, var, key)
|
||||
@ -68,10 +68,10 @@
|
||||
#define CONFIG_GET_STRING(var, key) CONFIG_GET_STRING_BASE(conf, g_config, var, key)
|
||||
#define CONFIG_GET_PATH(var, key) CONFIG_GET_PATH_BASE(conf, g_config, var, key)
|
||||
|
||||
#define CONFIG_GET_BOOL_EXTERN(var, key) CONFIG_GET_BOOL_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_INT_EXTERN(var, key) CONFIG_GET_INT_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_FLOAT_EXTERN(var, key) CONFIG_GET_FLOAT_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_STRING_EXTERN(var, key) CONFIG_GET_STRING_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_PATH_EXTERN(var, key) CONFIG_GET_PATH_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_BOOL_EXTERN(var, key) CONFIG_GET_BOOL_BASE(conf, global, var, key)
|
||||
#define CONFIG_GET_INT_EXTERN(var, key) CONFIG_GET_INT_BASE(conf, global, var, key)
|
||||
#define CONFIG_GET_FLOAT_EXTERN(var, key) CONFIG_GET_FLOAT_BASE(conf, global, var, key)
|
||||
#define CONFIG_GET_STRING_EXTERN(var, key) CONFIG_GET_STRING_BASE(conf, global, var, key)
|
||||
#define CONFIG_GET_PATH_EXTERN(var, key) CONFIG_GET_PATH_BASE(conf, global, var, key)
|
||||
|
||||
#endif
|
||||
|
@ -1674,7 +1674,13 @@ static void main_clear_state(bool inited)
|
||||
unsigned i;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
memset(settings, 0, sizeof(*settings));
|
||||
if (settings)
|
||||
config_free();
|
||||
|
||||
settings = config_init();
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
if (inited)
|
||||
rarch_main_command(RARCH_CMD_DRIVERS_DEINIT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user