Add ScreenSettings_delete helper

This commit is contained in:
Christian Göttsche 2021-12-08 14:20:54 +01:00
parent 3cfdf66d9a
commit df1914f429
2 changed files with 9 additions and 3 deletions

View File

@ -75,9 +75,7 @@ void Settings_delete(Settings* this) {
free(this->hColumns); free(this->hColumns);
if (this->screens) { if (this->screens) {
for (unsigned int i = 0; this->screens[i]; i++) { for (unsigned int i = 0; this->screens[i]; i++) {
free(this->screens[i]->name); ScreenSettings_delete(this->screens[i]);
free(this->screens[i]->fields);
free(this->screens[i]);
} }
free(this->screens); free(this->screens);
} }
@ -285,6 +283,12 @@ ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char*
return ss; return ss;
} }
void ScreenSettings_delete(ScreenSettings* this) {
free(this->name);
free(this->fields);
free(this);
}
static ScreenSettings* Settings_defaultScreens(Settings* this) { static ScreenSettings* Settings_defaultScreens(Settings* this) {
if (this->nScreens) if (this->nScreens)
return this->screens[0]; return this->screens[0];

View File

@ -118,6 +118,8 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicColumns);
ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char* line); ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char* line);
void ScreenSettings_delete(ScreenSettings* this);
void ScreenSettings_invertSortOrder(ScreenSettings* this); void ScreenSettings_invertSortOrder(ScreenSettings* this);
void ScreenSettings_setSortKey(ScreenSettings* this, ProcessField sortKey); void ScreenSettings_setSortKey(ScreenSettings* this, ProcessField sortKey);