Skip to content

Commit ba6f54c

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 45d0ac8 commit ba6f54c

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

‎Settings.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,19 +892,14 @@ Settings* Settings_new(const Machine* host, Hashtable* dynamicMeters, Hashtable*
892892
home = (pw && pw->pw_dir && pw->pw_dir[0] == '/') ? pw->pw_dir : "";
893893
}
894894
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
895-
char* configDir = NULL;
896895
char* htopDir = NULL;
897896
if (xdgConfigHome && xdgConfigHome[0] == '/') {
898-
this->initialFilename = String_cat(xdgConfigHome, "/htop/htoprc");
899-
configDir = xStrdup(xdgConfigHome);
900897
htopDir = String_cat(xdgConfigHome, "/htop");
901898
} else {
902-
this->initialFilename = String_cat(home, CONFIGDIR "/htop/htoprc");
903-
configDir = String_cat(home, CONFIGDIR);
904899
htopDir = String_cat(home, CONFIGDIR "/htop");
905900
}
901+
this->initialFilename = String_cat(htopDir, "/htoprc");
906902
free(htopDir);
907-
free(configDir);
908903

909904
legacyDotfile = String_cat(home, "/.htoprc");
910905
}

0 commit comments

Comments
 (0)