mirror of
https://github.com/libretro/RetroArch
synced 2025-04-03 10:21:31 +00:00
Move memory allocation to populate_settings functions
This commit is contained in:
parent
03bb3d847d
commit
6db73d0208
@ -1290,7 +1290,7 @@ static void config_get_hex_base(config_file_t *conf, const char *key, unsigned *
|
|||||||
count++; \
|
count++; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int populate_settings_bool(settings_t *settings, struct config_bool_setting_ptr *out)
|
static int populate_settings_bool(settings_t *settings, struct config_bool_setting_ptr **out)
|
||||||
{
|
{
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
@ -1418,7 +1418,9 @@ static int populate_settings_bool(settings_t *settings, struct config_bool_setti
|
|||||||
SETTING_BOOL("input_autodetect_enable", &settings->input.autodetect_enable);
|
SETTING_BOOL("input_autodetect_enable", &settings->input.autodetect_enable);
|
||||||
SETTING_BOOL("audio_rate_control", &settings->audio.rate_control);
|
SETTING_BOOL("audio_rate_control", &settings->audio.rate_control);
|
||||||
|
|
||||||
memcpy(out, tmp, sizeof(struct config_bool_setting_ptr) * count);
|
*out =
|
||||||
|
(struct config_bool_setting_ptr*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting_ptr));
|
||||||
|
memcpy(*out, tmp, sizeof(struct config_bool_setting_ptr) * count);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -1434,7 +1436,7 @@ static int populate_settings_bool(settings_t *settings, struct config_bool_setti
|
|||||||
count++; \
|
count++; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int populate_settings_float(settings_t *settings, struct config_float_setting_ptr *out)
|
static int populate_settings_float(settings_t *settings, struct config_float_setting_ptr **out)
|
||||||
{
|
{
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
struct config_float_setting_ptr *tmp = NULL;
|
struct config_float_setting_ptr *tmp = NULL;
|
||||||
@ -1461,7 +1463,9 @@ static int populate_settings_float(settings_t *settings, struct config_float_set
|
|||||||
SETTING_FLOAT("slowmotion_ratio", &settings->slowmotion_ratio);
|
SETTING_FLOAT("slowmotion_ratio", &settings->slowmotion_ratio);
|
||||||
SETTING_FLOAT("input_axis_threshold", &settings->input.axis_threshold);
|
SETTING_FLOAT("input_axis_threshold", &settings->input.axis_threshold);
|
||||||
|
|
||||||
memcpy(out, tmp, sizeof(struct config_float_setting_ptr) * count);
|
*out =
|
||||||
|
(struct config_float_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting_ptr));
|
||||||
|
memcpy(*out, tmp, sizeof(struct config_float_setting_ptr) * count);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -1592,14 +1596,8 @@ static bool config_load_file(const char *path, bool set_defaults,
|
|||||||
if (!settings)
|
if (!settings)
|
||||||
settings = config_get_ptr();
|
settings = config_get_ptr();
|
||||||
|
|
||||||
float_settings =
|
bool_settings_size = populate_settings_bool (settings, &bool_settings);
|
||||||
(struct config_float_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting_ptr));
|
float_settings_size = populate_settings_float (settings, &float_settings);
|
||||||
|
|
||||||
bool_settings =
|
|
||||||
(struct config_bool_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting_ptr));
|
|
||||||
|
|
||||||
bool_settings_size = populate_settings_bool (settings, bool_settings);
|
|
||||||
float_settings_size = populate_settings_float (settings, float_settings);
|
|
||||||
int_settings_size = populate_settings_int (settings, &int_settings);
|
int_settings_size = populate_settings_int (settings, &int_settings);
|
||||||
|
|
||||||
(void)path_settings_size;
|
(void)path_settings_size;
|
||||||
@ -2895,7 +2893,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
|
|||||||
count++; \
|
count++; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
static int populate_settings_string(settings_t *settings, struct config_string_setting_ptr *out)
|
static int populate_settings_string(settings_t *settings, struct config_string_setting_ptr **out)
|
||||||
{
|
{
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
struct config_string_setting_ptr *tmp = NULL;
|
struct config_string_setting_ptr *tmp = NULL;
|
||||||
@ -2935,7 +2933,9 @@ static int populate_settings_string(settings_t *settings, struct config_string_s
|
|||||||
SETTING_STRING("bundle_assets_src_path", settings->path.bundle_assets_src);
|
SETTING_STRING("bundle_assets_src_path", settings->path.bundle_assets_src);
|
||||||
SETTING_STRING("bundle_assets_dst_path", settings->path.bundle_assets_dst);
|
SETTING_STRING("bundle_assets_dst_path", settings->path.bundle_assets_dst);
|
||||||
|
|
||||||
memcpy(out, tmp, sizeof(struct config_string_setting_ptr) * count);
|
*out =
|
||||||
|
(struct config_string_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting_ptr));
|
||||||
|
memcpy(*out, tmp, sizeof(struct config_string_setting_ptr) * count);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -2952,7 +2952,7 @@ static int populate_settings_string(settings_t *settings, struct config_string_s
|
|||||||
count++; \
|
count++; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
static int populate_settings_path(settings_t *settings, struct config_path_setting_ptr *out)
|
static int populate_settings_path(settings_t *settings, struct config_path_setting_ptr **out)
|
||||||
{
|
{
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
struct config_path_setting_ptr *tmp = NULL;
|
struct config_path_setting_ptr *tmp = NULL;
|
||||||
@ -3052,7 +3052,9 @@ static int populate_settings_path(settings_t *settings, struct config_path_setti
|
|||||||
"screenshot_directory", true,
|
"screenshot_directory", true,
|
||||||
settings->directory.screenshot);
|
settings->directory.screenshot);
|
||||||
|
|
||||||
memcpy(out, tmp, sizeof(struct config_path_setting_ptr) * count);
|
*out =
|
||||||
|
(struct config_path_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_path_setting_ptr));
|
||||||
|
memcpy(*out, tmp, sizeof(struct config_path_setting_ptr) * count);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -3092,23 +3094,11 @@ bool config_save_file(const char *path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_settings =
|
bool_settings_size = populate_settings_bool (settings, &bool_settings);
|
||||||
(struct config_bool_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting_ptr));
|
|
||||||
|
|
||||||
float_settings =
|
|
||||||
(struct config_float_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting_ptr));
|
|
||||||
|
|
||||||
string_settings =
|
|
||||||
(struct config_string_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting_ptr));
|
|
||||||
|
|
||||||
path_settings =
|
|
||||||
(struct config_path_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_path_setting_ptr));
|
|
||||||
|
|
||||||
bool_settings_size = populate_settings_bool (settings, bool_settings);
|
|
||||||
int_settings_size = populate_settings_int (settings, &int_settings);
|
int_settings_size = populate_settings_int (settings, &int_settings);
|
||||||
float_settings_size = populate_settings_float (settings, float_settings);
|
float_settings_size = populate_settings_float (settings, &float_settings);
|
||||||
string_settings_size = populate_settings_string(settings, string_settings);
|
string_settings_size = populate_settings_string(settings, &string_settings);
|
||||||
path_settings_size = populate_settings_path (settings, path_settings);
|
path_settings_size = populate_settings_path (settings, &path_settings);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3309,27 +3299,6 @@ bool config_save_overrides(int override_type)
|
|||||||
|
|
||||||
settings = (settings_t*)calloc(1, sizeof(settings_t));
|
settings = (settings_t*)calloc(1, sizeof(settings_t));
|
||||||
|
|
||||||
bool_settings =
|
|
||||||
(struct config_bool_setting_ptr*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting_ptr));
|
|
||||||
bool_overrides =
|
|
||||||
(struct config_bool_setting_ptr*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting_ptr));
|
|
||||||
|
|
||||||
float_settings =
|
|
||||||
(struct config_float_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting_ptr));
|
|
||||||
float_overrides =
|
|
||||||
(struct config_float_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting_ptr));
|
|
||||||
|
|
||||||
string_settings =
|
|
||||||
(struct config_string_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting_ptr));
|
|
||||||
string_overrides =
|
|
||||||
(struct config_string_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting_ptr));
|
|
||||||
|
|
||||||
path_settings =
|
|
||||||
(struct config_path_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_path_setting_ptr));
|
|
||||||
path_overrides =
|
|
||||||
(struct config_path_setting_ptr*) malloc(PATH_MAX_LENGTH * sizeof(struct config_path_setting_ptr));
|
|
||||||
|
|
||||||
|
|
||||||
fill_pathname_application_special(config_directory, sizeof(config_directory),
|
fill_pathname_application_special(config_directory, sizeof(config_directory),
|
||||||
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
|
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
|
||||||
|
|
||||||
@ -3358,16 +3327,16 @@ bool config_save_overrides(int override_type)
|
|||||||
/* Load the original config file in memory */
|
/* Load the original config file in memory */
|
||||||
config_load_file(global->path.config, false, settings);
|
config_load_file(global->path.config, false, settings);
|
||||||
|
|
||||||
bool_settings_size = populate_settings_bool(settings, bool_settings);
|
bool_settings_size = populate_settings_bool(settings, &bool_settings);
|
||||||
populate_settings_bool (overrides, bool_overrides);
|
populate_settings_bool (overrides, &bool_overrides);
|
||||||
int_settings_size = populate_settings_int(settings, &int_settings);
|
int_settings_size = populate_settings_int(settings, &int_settings);
|
||||||
populate_settings_int (overrides, &int_overrides);
|
populate_settings_int (overrides, &int_overrides);
|
||||||
float_settings_size = populate_settings_float(settings, float_settings);
|
float_settings_size = populate_settings_float(settings, &float_settings);
|
||||||
populate_settings_float (overrides, float_overrides);
|
populate_settings_float (overrides, &float_overrides);
|
||||||
string_settings_size = populate_settings_string(settings, string_settings);
|
string_settings_size = populate_settings_string(settings, &string_settings);
|
||||||
populate_settings_string (overrides, string_overrides);
|
populate_settings_string (overrides, &string_overrides);
|
||||||
path_settings_size = populate_settings_path(settings, path_settings);
|
path_settings_size = populate_settings_path(settings, &path_settings);
|
||||||
populate_settings_path (overrides, path_overrides);
|
populate_settings_path (overrides, &path_overrides);
|
||||||
|
|
||||||
RARCH_LOG("[overrides] looking for changed settings... \n");
|
RARCH_LOG("[overrides] looking for changed settings... \n");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user