Skip to content

Commit 38e0e08

Browse files
committed
Settings_new() code shrink
No need to temporarily duplicate the XDG_CONFIG_HOME path string. Note that I didn't simplify or leave out the allocation of "$XDG_CONFIG_HOME/htop" or "$HOME/.config/htop" string because I suspect this string might be reused in the future. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 0bf0fe1 commit 38e0e08

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

Settings.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -896,19 +896,14 @@ Settings* Settings_new(const Machine* host, Hashtable* dynamicMeters, Hashtable*
896896
home = (pw && pw->pw_dir && pw->pw_dir[0] == '/') ? pw->pw_dir : "";
897897
}
898898
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
899-
char* configDir = NULL;
900899
char* htopDir = NULL;
901900
if (xdgConfigHome && xdgConfigHome[0] == '/') {
902-
this->initialFilename = String_cat(xdgConfigHome, "/htop/htoprc");
903-
configDir = xStrdup(xdgConfigHome);
904901
htopDir = String_cat(xdgConfigHome, "/htop");
905902
} else {
906-
this->initialFilename = String_cat(home, CONFIGDIR "/htop/htoprc");
907-
configDir = String_cat(home, CONFIGDIR);
908903
htopDir = String_cat(home, CONFIGDIR "/htop");
909904
}
905+
this->initialFilename = String_cat(htopDir, "/htoprc");
910906
free(htopDir);
911-
free(configDir);
912907

913908
legacyDotfile = String_cat(home, "/.htoprc");
914909
}

0 commit comments

Comments
 (0)