mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 16:20:39 +00:00
config_set_string: simplify
This commit is contained in:
parent
a954118faf
commit
b681b2af49
@ -968,39 +968,46 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
|
|||||||
if (!conf || !key || !val)
|
if (!conf || !key || !val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
last = (conf->guaranteed_no_duplicates && conf->last) ?
|
last = conf->entries;
|
||||||
conf->last : conf->entries;
|
|
||||||
entry = conf->guaranteed_no_duplicates ?
|
|
||||||
NULL : config_get_entry(conf, key, &last);
|
|
||||||
|
|
||||||
if (entry)
|
if (conf->guaranteed_no_duplicates)
|
||||||
{
|
{
|
||||||
/* An entry corresponding to 'key' already exists
|
if (conf->last)
|
||||||
* > Check if it's read only */
|
last = conf->last;
|
||||||
if (entry->readonly)
|
}
|
||||||
return;
|
else
|
||||||
|
{
|
||||||
|
entry = config_get_entry(conf, key, &last);
|
||||||
|
|
||||||
/* Check whether value is currently set */
|
if (entry)
|
||||||
if (entry->value)
|
|
||||||
{
|
{
|
||||||
/* Do nothing if value is unchanged */
|
/* An entry corresponding to 'key' already exists
|
||||||
if (string_is_equal(entry->value, val))
|
* > Check if it's read only */
|
||||||
|
if (entry->readonly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Value is to be updated
|
/* Check whether value is currently set */
|
||||||
* > Free existing */
|
if (entry->value)
|
||||||
free(entry->value);
|
{
|
||||||
}
|
/* Do nothing if value is unchanged */
|
||||||
|
if (string_is_equal(entry->value, val))
|
||||||
|
return;
|
||||||
|
|
||||||
/* Update value */
|
/* Value is to be updated
|
||||||
entry->value = strdup(val);
|
* > Free existing */
|
||||||
conf->modified = true;
|
free(entry->value);
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
/* Update value */
|
||||||
|
entry->value = strdup(val);
|
||||||
|
conf->modified = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Entry corresponding to 'key' does not exist
|
/* Entry corresponding to 'key' does not exist
|
||||||
* > Create new entry */
|
* > Create new entry */
|
||||||
entry = (struct config_entry_list*)malloc(sizeof(*entry));
|
entry = (struct config_entry_list*)malloc(sizeof(*entry));
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user