mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
Reduce char arrays
This commit is contained in:
parent
16209a0936
commit
1e83bfb971
@ -28,55 +28,46 @@
|
||||
int config_userdata_get_float(void *userdata, const char *key_str,
|
||||
float *value, float default_value)
|
||||
{
|
||||
bool got;
|
||||
char key[2][256];
|
||||
char key[256];
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
|
||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||
|
||||
got = config_get_float (usr->conf, key[0], value);
|
||||
got = got || config_get_float(usr->conf, key[1], value);
|
||||
|
||||
if (!got)
|
||||
fill_pathname_join_delim(key, usr->prefix[0], key_str, '_', sizeof(key));
|
||||
if (config_get_float(usr->conf, key, value))
|
||||
return true;
|
||||
*value = default_value;
|
||||
return got;
|
||||
fill_pathname_join_delim(key, usr->prefix[1], key_str, '_', sizeof(key));
|
||||
if (config_get_float(usr->conf, key, value))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int config_userdata_get_int(void *userdata, const char *key_str,
|
||||
int *value, int default_value)
|
||||
{
|
||||
bool got;
|
||||
char key[2][256];
|
||||
char key[256];
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
|
||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||
|
||||
got = config_get_int (usr->conf, key[0], value);
|
||||
got = got || config_get_int(usr->conf, key[1], value);
|
||||
|
||||
if (!got)
|
||||
fill_pathname_join_delim(key, usr->prefix[0], key_str, '_', sizeof(key));
|
||||
if (config_get_int(usr->conf, key, value))
|
||||
return true;
|
||||
*value = default_value;
|
||||
return got;
|
||||
fill_pathname_join_delim(key, usr->prefix[1], key_str, '_', sizeof(key));
|
||||
if (config_get_int(usr->conf, key, value))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int config_userdata_get_hex(void *userdata, const char *key_str,
|
||||
unsigned *value, unsigned default_value)
|
||||
{
|
||||
bool got;
|
||||
char key[2][256];
|
||||
char key[256];
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
|
||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||
|
||||
got = config_get_hex(usr->conf, key[0], value);
|
||||
got = got || config_get_hex(usr->conf, key[1], value);
|
||||
|
||||
if (!got)
|
||||
fill_pathname_join_delim(key, usr->prefix[0], key_str, '_', sizeof(key));
|
||||
if (config_get_hex(usr->conf, key, value))
|
||||
return true;
|
||||
*value = default_value;
|
||||
return got;
|
||||
fill_pathname_join_delim(key, usr->prefix[1], key_str, '_', sizeof(key));
|
||||
if (config_get_hex(usr->conf, key, value))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int config_userdata_get_float_array(void *userdata, const char *key_str,
|
||||
@ -84,14 +75,14 @@ int config_userdata_get_float_array(void *userdata, const char *key_str,
|
||||
const float *default_values, unsigned num_default_values)
|
||||
{
|
||||
char key[2][256];
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
char *str = NULL;
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
|
||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||
|
||||
if ( config_get_string(usr->conf, key[0], &str) ||
|
||||
config_get_string(usr->conf, key[1], &str))
|
||||
if ( config_get_string(usr->conf, key[0], &str)
|
||||
|| config_get_string(usr->conf, key[1], &str))
|
||||
{
|
||||
unsigned i;
|
||||
struct string_list list = {0};
|
||||
@ -117,13 +108,13 @@ int config_userdata_get_int_array(void *userdata, const char *key_str,
|
||||
const int *default_values, unsigned num_default_values)
|
||||
{
|
||||
char key[2][256];
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
char *str = NULL;
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||
|
||||
if ( config_get_string(usr->conf, key[0], &str) ||
|
||||
config_get_string(usr->conf, key[1], &str))
|
||||
if ( config_get_string(usr->conf, key[0], &str)
|
||||
|| config_get_string(usr->conf, key[1], &str))
|
||||
{
|
||||
unsigned i;
|
||||
struct string_list list = {0};
|
||||
@ -148,13 +139,13 @@ int config_userdata_get_string(void *userdata, const char *key_str,
|
||||
char **output, const char *default_output)
|
||||
{
|
||||
char key[2][256];
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
char *str = NULL;
|
||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||
|
||||
if ( config_get_string(usr->conf, key[0], &str) ||
|
||||
config_get_string(usr->conf, key[1], &str))
|
||||
if ( config_get_string(usr->conf, key[0], &str)
|
||||
|| config_get_string(usr->conf, key[1], &str))
|
||||
{
|
||||
*output = str;
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user