mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Release config on closing to limit leaked memory
This commit is contained in:
15
src/config.c
15
src/config.c
@@ -396,6 +396,21 @@ void config_set_defaults()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void config_release()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < countof(_sectionDefinitions); i++) {
|
||||||
|
config_section_definition *section = &_sectionDefinitions[i];
|
||||||
|
for (int j = 0; j < section->property_definitions_count; j++) {
|
||||||
|
config_property_definition *property = §ion->property_definitions[j];
|
||||||
|
value_union *destValue = (value_union*)((size_t)section->base_address + (size_t)property->offset);
|
||||||
|
if (property->type == CONFIG_VALUE_TYPE_STRING) {
|
||||||
|
utf8 **dst = (utf8**)&(destValue->value_string);
|
||||||
|
SafeFree(*dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void config_get_default_path(utf8 *outPath)
|
void config_get_default_path(utf8 *outPath)
|
||||||
{
|
{
|
||||||
platform_get_user_directory(outPath, NULL);
|
platform_get_user_directory(outPath, NULL);
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ extern uint16 gShortcutKeys[SHORTCUT_COUNT];
|
|||||||
|
|
||||||
void config_get_default_path(utf8 *outPath);
|
void config_get_default_path(utf8 *outPath);
|
||||||
void config_set_defaults();
|
void config_set_defaults();
|
||||||
|
void config_release();
|
||||||
bool config_open_default();
|
bool config_open_default();
|
||||||
bool config_save_default();
|
bool config_save_default();
|
||||||
|
|
||||||
|
|||||||
@@ -171,18 +171,24 @@ void colour_scheme_update_by_class(rct_window *window, rct_windowclass classific
|
|||||||
window->flags |= WF_TRANSPARENT;
|
window->flags |= WF_TRANSPARENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void theme_set_preset_string(const utf8string preset)
|
||||||
|
{
|
||||||
|
SafeFree(gConfigInterface.current_theme_preset);
|
||||||
|
gConfigInterface.current_theme_preset = strdup(preset);
|
||||||
|
}
|
||||||
|
|
||||||
void theme_change_preset(int preset)
|
void theme_change_preset(int preset)
|
||||||
{
|
{
|
||||||
if (preset >= 0 && preset < gConfigThemes.num_presets) {
|
if (preset >= 0 && preset < gConfigThemes.num_presets) {
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case 0:
|
case 0:
|
||||||
gConfigInterface.current_theme_preset = "*RCT2";
|
theme_set_preset_string("*RCT2");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
gConfigInterface.current_theme_preset = "*RCT1";
|
theme_set_preset_string("*RCT1");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gConfigInterface.current_theme_preset = gConfigThemes.presets[preset].name;
|
theme_set_preset_string(gConfigThemes.presets[preset].name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gCurrentTheme = preset;
|
gCurrentTheme = preset;
|
||||||
|
|||||||
@@ -322,6 +322,7 @@ void openrct2_dispose()
|
|||||||
network_close();
|
network_close();
|
||||||
http_dispose();
|
http_dispose();
|
||||||
language_close_all();
|
language_close_all();
|
||||||
|
config_release();
|
||||||
platform_free();
|
platform_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user