diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-12-25 20:23:53 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-12-25 20:23:53 +0000 |
commit | 81e44312b4976d5516f129f36a67fe381bcb6883 (patch) | |
tree | 01f7dcdce2275ab6026f0f56762500fc8fa0a54b | |
parent | 93233a67ea124b8127b50b45cd91c95ca022f8e7 (diff) |
Use strdup explicitly
-rw-r--r-- | AffinityPanel.c | 2 | ||||
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | ColorsPanel.c | 3 | ||||
-rw-r--r-- | ColorsPanel.h | 1 | ||||
-rw-r--r-- | DisplayOptionsPanel.c | 22 | ||||
-rw-r--r-- | FunctionBar.c | 6 | ||||
-rw-r--r-- | ListItem.c | 2 | ||||
-rw-r--r-- | OpenFilesScreen.c | 1 | ||||
-rw-r--r-- | OpenFilesScreen.h | 2 | ||||
-rw-r--r-- | ProcessList.c | 6 | ||||
-rw-r--r-- | Settings.h | 1 | ||||
-rw-r--r-- | String.c | 6 | ||||
-rw-r--r-- | String.h | 3 | ||||
-rw-r--r-- | UsersTable.c | 5 | ||||
-rw-r--r-- | UsersTable.h | 3 | ||||
-rw-r--r-- | htop.c | 4 | ||||
-rw-r--r-- | htop.h | 4 |
17 files changed, 38 insertions, 36 deletions
diff --git a/AffinityPanel.c b/AffinityPanel.c index 404104a1..655af607 100644 --- a/AffinityPanel.c +++ b/AffinityPanel.c @@ -38,7 +38,7 @@ Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity) { } else { mode = false; } - Panel_add(this, (Object*) CheckItem_new(String_copy(number), NULL, mode)); + Panel_add(this, (Object*) CheckItem_new(strdup(number), NULL, mode)); } return this; } @@ -1,6 +1,9 @@ What's new in version 1.0.1 +* Move .htoprc to XDG-compliant path ~/.config/htop/htoprc, + respecting $XDG_CONFIG_HOME + (thanks to Hadzhimurad Ustarkhan for the suggestion.) * Safer behavior on the kill screen, to make it harder to kill the wrong process. * BUGFIX: keep main panel up-to-date when running the screen manager, to fix crash when processes die while on the F9/Kill screen. diff --git a/ColorsPanel.c b/ColorsPanel.c index b4ee5f29..374e1df2 100644 --- a/ColorsPanel.c +++ b/ColorsPanel.c @@ -1,4 +1,5 @@ +#include "config.h" #include "CRT.h" #include "ColorsPanel.h" @@ -88,7 +89,7 @@ ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) { Panel_setHeader(super, "Colors"); for (int i = 0; ColorSchemes[i] != NULL; i++) { - Panel_add(super, (Object*) CheckItem_new(String_copy(ColorSchemes[i]), NULL, false)); + Panel_add(super, (Object*) CheckItem_new(strdup(ColorSchemes[i]), NULL, false)); } CheckItem_set((CheckItem*)Panel_get(super, settings->colorScheme), true); return this; diff --git a/ColorsPanel.h b/ColorsPanel.h index fac99639..f32152bf 100644 --- a/ColorsPanel.h +++ b/ColorsPanel.h @@ -3,6 +3,7 @@ #ifndef HEADER_ColorsPanel #define HEADER_ColorsPanel +#include "config.h" #include "CRT.h" #include "Panel.h" diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index 71d73097..c2c0d33e 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -65,16 +65,16 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* super->eventHandler = DisplayOptionsPanel_eventHandler; Panel_setHeader(super, "Display options"); - Panel_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Hide userland threads"), &(settings->pl->hideUserlandThreads), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Display threads in a different color"), &(settings->pl->highlightThreads), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Show custom thread names"), &(settings->pl->showThreadNames), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight large numbers in memory counters"), &(settings->pl->highlightMegabytes), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)"), &(settings->pl->detailedCPUTime), false)); - Panel_add(super, (Object*) CheckItem_new(String_copy("Count CPUs from 0 instead of 1"), &(settings->pl->countCPUsFromZero), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Tree view"), &(settings->pl->treeView), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Shadow other users' processes"), &(settings->pl->shadowOtherUsers), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Hide kernel threads"), &(settings->pl->hideKernelThreads), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Hide userland threads"), &(settings->pl->hideUserlandThreads), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Display threads in a different color"), &(settings->pl->highlightThreads), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Show custom thread names"), &(settings->pl->showThreadNames), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Highlight program \"basename\""), &(settings->pl->highlightBaseName), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Highlight large numbers in memory counters"), &(settings->pl->highlightMegabytes), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Leave a margin around header"), &(settings->header->margin), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)"), &(settings->pl->detailedCPUTime), false)); + Panel_add(super, (Object*) CheckItem_new(strdup("Count CPUs from 0 instead of 1"), &(settings->pl->countCPUsFromZero), false)); return this; } diff --git a/FunctionBar.c b/FunctionBar.c index ef0fcba2..ba657492 100644 --- a/FunctionBar.c +++ b/FunctionBar.c @@ -54,8 +54,8 @@ FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* eve this->events = malloc(sizeof(int) * 15); int i = 0; while (i < 15 && functions[i]) { - this->functions[i] = String_copy(functions[i]); - this->keys[i] = String_copy(keys[i]); + this->functions[i] = strdup(functions[i]); + this->keys[i] = strdup(keys[i]); this->events[i] = events[i]; i++; } @@ -89,7 +89,7 @@ void FunctionBar_setLabel(FunctionBar* this, int event, const char* text) { for (int i = 0; i < this->size; i++) { if (this->events[i] == event) { free(this->functions[i]); - this->functions[i] = String_copy(text); + this->functions[i] = strdup(text); break; } } @@ -49,7 +49,7 @@ ListItem* ListItem_new(const char* value, int key) { Object_setClass(this, LISTITEM_CLASS); ((Object*)this)->display = ListItem_display; ((Object*)this)->delete = ListItem_delete; - this->value = String_copy(value); + this->value = strdup(value); this->key = key; return this; } diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c index b4ec11ae..98110016 100644 --- a/OpenFilesScreen.c +++ b/OpenFilesScreen.c @@ -5,7 +5,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define _GNU_SOURCE #include <stdio.h> #include <unistd.h> #include <stdbool.h> diff --git a/OpenFilesScreen.h b/OpenFilesScreen.h index a5d3cbc7..78694054 100644 --- a/OpenFilesScreen.h +++ b/OpenFilesScreen.h @@ -9,7 +9,7 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define _GNU_SOURCE +#include "config.h" #include <stdio.h> #include <unistd.h> #include <stdbool.h> diff --git a/ProcessList.c b/ProcessList.c index 224c18c9..d33d83b8 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -617,7 +617,7 @@ static bool ProcessList_readCmdlineFile(Process* process, const char* dirname, c command[amtRead] = '\0'; fclose(file); free(process->comm); - process->comm = String_copy(command); + process->comm = strdup(command); return true; } @@ -710,11 +710,11 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P if (process->state == 'Z') { free(process->comm); - process->comm = String_copy(command); + process->comm = strdup(command); } else if (Process_isThread(process)) { if (this->showThreadNames || Process_isKernelThread(process) || process->state == 'Z') { free(process->comm); - process->comm = String_copy(command); + process->comm = strdup(command); } else if (this->showingThreadNames) { if (! ProcessList_readCmdlineFile(process, dirname, name)) goto errorReadingProcess; @@ -9,6 +9,7 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ +#include "config.h" #include "String.h" #include "ProcessList.h" #include "Header.h" @@ -5,7 +5,7 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define _GNU_SOURCE +#include "config.h" #include "String.h" #include <string.h> #include <strings.h> @@ -18,10 +18,6 @@ in the source distribution for its full text. #define String_startsWith(s, match) (strstr((s), (match)) == (s)) }*/ -inline char* String_copy(const char* orig) { - return strdup(orig); -} - char* String_cat(const char* s1, const char* s2) { int l1 = strlen(s1); int l2 = strlen(s2); @@ -9,6 +9,7 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ +#include "config.h" #include <string.h> #include <strings.h> #include <stdlib.h> @@ -18,8 +19,6 @@ in the source distribution for its full text. #define String_startsWith(s, match) (strstr((s), (match)) == (s)) -extern char* String_copy(const char* orig); - char* String_cat(const char* s1, const char* s2); char* String_trim(const char* in); diff --git a/UsersTable.c b/UsersTable.c index 1c56da46..f05b815c 100644 --- a/UsersTable.c +++ b/UsersTable.c @@ -5,11 +5,12 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ +#include "config.h" #include "UsersTable.h" #include "Hashtable.h" -#include "String.h" #include <stdio.h> +#include <string.h> #include <strings.h> #include <pwd.h> #include <sys/types.h> @@ -40,7 +41,7 @@ char* UsersTable_getRef(UsersTable* this, unsigned int uid) { if (name == NULL) { struct passwd* userData = getpwuid(uid); if (userData != NULL) { - name = String_copy(userData->pw_name); + name = strdup(userData->pw_name); Hashtable_put(this->users, uid, name); } } diff --git a/UsersTable.h b/UsersTable.h index 7a591f78..6b3f2726 100644 --- a/UsersTable.h +++ b/UsersTable.h @@ -9,10 +9,11 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ +#include "config.h" #include "Hashtable.h" -#include "String.h" #include <stdio.h> +#include <string.h> #include <strings.h> #include <pwd.h> #include <sys/types.h> @@ -5,7 +5,8 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define _GNU_SOURCE +#include "config.h" + #include <unistd.h> #include <math.h> #include <sys/param.h> @@ -29,7 +30,6 @@ in the source distribution for its full text. #include "OpenFilesScreen.h" #include "AffinityPanel.h" -#include "config.h" #include "debug.h" //#link m @@ -9,7 +9,8 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define _GNU_SOURCE +#include "config.h" + #include <unistd.h> #include <math.h> #include <sys/param.h> @@ -33,7 +34,6 @@ in the source distribution for its full text. #include "OpenFilesScreen.h" #include "AffinityPanel.h" -#include "config.h" #include "debug.h" //#link m |