From 4c3b06d64039c8cedd0a671d335783dc0a6fc288 Mon Sep 17 00:00:00 2001 From: Sven <40953353+RetroSven@users.noreply.github.com> Date: Wed, 10 Oct 2018 11:10:49 -0400 Subject: [PATCH] bugfix cheat saving --- libretro-common/file/config_file.c | 7 ++++++- libretro-common/include/file/config_file.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 7dd671b662..846fa2c6fc 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -406,6 +406,7 @@ static config_file_t *config_file_new_internal( conf->path = NULL; conf->entries = NULL; conf->tail = NULL; + conf->last = NULL; conf->includes = NULL; conf->include_depth = 0; conf->guaranteed_no_duplicates = false ; @@ -558,6 +559,7 @@ config_file_t *config_file_new_from_string(const char *from_string) conf->path = NULL; conf->entries = NULL; conf->tail = NULL; + conf->last = NULL; conf->includes = NULL; conf->include_depth = 0; conf->guaranteed_no_duplicates = false ; @@ -842,7 +844,7 @@ bool config_get_bool(config_file_t *conf, const char *key, bool *in) void config_set_string(config_file_t *conf, const char *key, const char *val) { - struct config_entry_list *last = conf->entries; + struct config_entry_list *last = (conf->guaranteed_no_duplicates && conf->last) ? conf->last : conf->entries; struct config_entry_list *entry = conf->guaranteed_no_duplicates?NULL:config_get_entry(conf, key, &last); if (entry && !entry->readonly) @@ -868,6 +870,9 @@ void config_set_string(config_file_t *conf, const char *key, const char *val) last->next = entry; else conf->entries = entry; + + conf->last = entry ; + } void config_unset(config_file_t *conf, const char *key) diff --git a/libretro-common/include/file/config_file.h b/libretro-common/include/file/config_file.h index e55430472d..d2d5b026f7 100644 --- a/libretro-common/include/file/config_file.h +++ b/libretro-common/include/file/config_file.h @@ -57,6 +57,7 @@ struct config_file char *path; struct config_entry_list *entries; struct config_entry_list *tail; + struct config_entry_list *last; unsigned include_depth; bool guaranteed_no_duplicates;