From c1d0dc5ec04599be96e9645225b0d15ba826fdfc Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Mon, 8 Aug 2005 23:12:43 +0000 Subject: [PATCH] some fixes git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@87 7f574dfc-610e-0410-a909-a81674777703 --- Conky.kdevelop | 18 +++++++++--------- common.c | 2 +- conky.h | 1 + linux.c | 2 +- top.c | 8 +++++--- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Conky.kdevelop b/Conky.kdevelop index 94dc211f..795bbc0a 100644 --- a/Conky.kdevelop +++ b/Conky.kdevelop @@ -53,7 +53,7 @@ kdevgccoptions kdevgppoptions kdevpgf77options - -O2 -Wall -fexceptions -fomit-frame-pointer -fshort-enums -g3 + -O2 -Wall -fexceptions -fomit-frame-pointer -fshort-enums -g3 -CB @@ -68,18 +68,18 @@ --enable-debug=full --prefix=/usr --enable-mpd --enable-xft --enable-seti --enable-double-buffer --enable-own-window --enable-metar --enable-mldonkey --disable-x11 debug-no-x - - - + + + kdevgccoptions kdevgppoptions kdevpgf77options - - - + + + -O2 -Wall -fexceptions -fomit-frame-pointer -fshort-enums -g3 - - + + diff --git a/common.c b/common.c index 3833dd68..ef5e93f4 100644 --- a/common.c +++ b/common.c @@ -33,7 +33,7 @@ FILE *open_file(const char *file, int *reported) FILE *fp = fopen(file, "r"); if (!fp) { if (!reported || *reported == 0) { - ERR("can't open %s: %s", file, strerror(errno)); + CRIT_ERR("can't open %s: %s", file, strerror(errno)); if (reported) *reported = 1; } diff --git a/conky.h b/conky.h index f74e1df1..e7d219a5 100644 --- a/conky.h +++ b/conky.h @@ -9,6 +9,7 @@ #ifndef _conky_h_ #define _conky_h_ +#undef MALLOC_CHECK_ //#include #include "config.h" diff --git a/linux.c b/linux.c index d31489b4..7a8a9719 100644 --- a/linux.c +++ b/linux.c @@ -279,7 +279,7 @@ inline void update_wifi_stats() net_wireless_fp = open_file("/proc/net/wireless", &rep); else fseek(net_wireless_fp, 0, SEEK_SET); - if (!net_wireless_fp) + if (net_wireless_fp == NULL) return; fgets(buf, 255, net_wireless_fp); /* garbage */ diff --git a/top.c b/top.c index a7821ac9..511e3b57 100644 --- a/top.c +++ b/top.c @@ -371,7 +371,7 @@ inline static void calc_cpu_each(int total) /* * Result is stored in decreasing order in best[0-9]. */ - +#define MAX_TOP_SIZE 400 /* this is plenty big */ static struct process **sorttmp; static size_t sorttmp_size = 10; @@ -408,7 +408,7 @@ inline void process_find_top(struct process **cpu, struct process **mem) if (i < sorttmp_size && pr->counted) { sorttmp[i] = pr; i++; - } else if (i == sorttmp_size && pr->counted) { + } else if (i == sorttmp_size && pr->counted && sorttmp_size < MAX_TOP_SIZE) { sorttmp_size++; sorttmp = realloc(sorttmp, @@ -420,6 +420,7 @@ inline void process_find_top(struct process **cpu, struct process **mem) pr = pr->next; } if (i + 1 < sorttmp_size) { + sorttmp_size--; sorttmp = realloc(sorttmp, sizeof(struct process) * sorttmp_size); @@ -461,7 +462,7 @@ inline void process_find_top(struct process **cpu, struct process **mem) if (i < sorttmp_size && pr->counted) { sorttmp[i] = pr; i++; - } else if (i == sorttmp_size && pr->counted) { + } else if (i == sorttmp_size && pr->counted && sorttmp_size < MAX_TOP_SIZE) { sorttmp_size++; sorttmp = realloc(sorttmp, @@ -473,6 +474,7 @@ inline void process_find_top(struct process **cpu, struct process **mem) pr = pr->next; } if (i + 1 < sorttmp_size) { + sorttmp_size--; sorttmp = realloc(sorttmp, sizeof(struct process) * sorttmp_size);