diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-12-08 13:02:58 +0100 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2021-12-08 14:55:14 +0100 |
commit | 3cfdf66d9aecb463026d1227a8ba159edd4e1cbd (patch) | |
tree | 40fe36286295cac2d251c00e23ecdc0d547967d1 /Settings.c | |
parent | fa9f260f63d657e25e756d7c1529dadee522db47 (diff) |
Settings: initialize default sort key for new screenpanel
Use C99 struct initialization, which also makes using calloc redundant.
htop: Process.c:1179: int Process_compareByKey_Base(const Process *, const Process *, ProcessField): Assertion `0 && "Process_compareByKey_Base: default key reached"' failed.
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -263,16 +263,20 @@ static void ScreenSettings_readFields(ScreenSettings* ss, Hashtable* columns, co } ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char* line) { - ScreenSettings* ss = xCalloc(1, sizeof(ScreenSettings)); - ss->name = xStrdup(name); - ss->fields = xCalloc(LAST_PROCESSFIELD, sizeof(ProcessField)); - ss->flags = 0; - ss->direction = 1; - ss->treeDirection = 1; - ss->treeSortKey = 1; - ss->treeView = false; - ss->treeViewAlwaysByPID = false; - ss->allBranchesCollapsed = false; + ScreenSettings* ss = xMalloc(sizeof(ScreenSettings)); + *ss = (ScreenSettings) { + .name = xStrdup(name), + .fields = xCalloc(LAST_PROCESSFIELD, sizeof(ProcessField)), + .flags = 0, + .direction = 1, + .treeDirection = 1, + .sortKey = PID, + .treeSortKey = PID, + .treeView = false, + .treeViewAlwaysByPID = false, + .allBranchesCollapsed = false, + }; + ScreenSettings_readFields(ss, this->dynamicColumns, line); this->screens[this->nScreens] = ss; this->nScreens++; |