mirror of https://github.com/mgba-emu/mgba.git
Util: Adding a null value to a Configuration removes the value
This commit is contained in:
parent
75557d11b2
commit
11bf4fdfda
|
@ -40,13 +40,17 @@ void ConfigurationSetValue(struct Configuration* configuration, const char* sect
|
|||
struct Table* currentSection = &configuration->root;
|
||||
if (section) {
|
||||
currentSection = HashTableLookup(&configuration->sections, section);
|
||||
if (!currentSection) {
|
||||
if (!currentSection && value) {
|
||||
currentSection = malloc(sizeof(*currentSection));
|
||||
HashTableInit(currentSection, 0, _sectionDeinit);
|
||||
HashTableInsert(&configuration->sections, section, currentSection);
|
||||
}
|
||||
}
|
||||
HashTableInsert(currentSection, key, strdup(value));
|
||||
if (value) {
|
||||
HashTableInsert(currentSection, key, strdup(value));
|
||||
} else {
|
||||
HashTableRemove(currentSection, key);
|
||||
}
|
||||
}
|
||||
|
||||
const char* ConfigurationGetValue(const struct Configuration* configuration, const char* section, const char* key) {
|
||||
|
|
Loading…
Reference in New Issue