Patch by Dwayne C. Litzenberger <dl...@dlitz.net> to fix Debian bug #224732.

Obtained from [1].

[1] 
https://sources.debian.net/src/wmtop/0.84-12/debian/patches/fix_incorrect_memory_usage.patch/
---
 wmtop/wmtop.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/wmtop/wmtop.c b/wmtop/wmtop.c
index 1c0895f..b5b8441 100644
--- a/wmtop/wmtop.c
+++ b/wmtop/wmtop.c
@@ -843,7 +843,7 @@ void calc_cpu_each(int total) {
 #if defined(LINUX)
 int calc_mem_total() {
     int ps;
-    char line[512];
+    char line[1024];
     char *ptr;
     int rc;
 
@@ -853,13 +853,16 @@ int calc_mem_total() {
     if (rc<0)
        return 0;
 
-    if ((ptr = strstr(line, "Mem:")) == NULL) {
-        return 0;
-    } else {
+    if ((ptr = strstr(line, "Mem:")) != NULL) {
         ptr += 4;
         return atoi(ptr);
+    } else if ((ptr = strstr(line, "MemTotal:")) != NULL) {
+        /* The "Mem:" line has been removed in Linux 2.6 */
+        ptr += 9;
+        return atoi(ptr) << 10; /* MemTotal is given in kiB */
+    } else {
+        return 0;
     }
-
 }
 #endif /* defined(LINUX) */
 
-- 
2.5.0


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to