Fixed top_mem as per Nattfodd's email on conky-development list
authorBrenden Matthews <brenden1@rty.ca>
Thu, 29 Sep 2005 03:34:05 +0000 (03:34 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Thu, 29 Sep 2005 03:34:05 +0000 (03:34 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@338 7f574dfc-610e-0410-a909-a81674777703

ChangeLog
src/top.c

index 9eba362..1c50db7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 2005-09-29
        * Fixed build on FreeBSD for non-i386
+       * Made it so top_mem doesn't show all the forks of one process
 
 2005-09-27
        * Fixed small bug in config parsing (thanks robgrady, bug 1306032)
index 1ffe45b..5fe3684 100644 (file)
--- a/src/top.c
+++ b/src/top.c
@@ -405,7 +405,7 @@ inline void process_find_top(struct process **cpu, struct process **mem)
                assert(sorttmp != NULL);
        }
        int total;
-       unsigned int i/*, max*/;
+       unsigned int i, j;
 
        total = calc_cpu_total();       /* calculate the total of the processor */
 
@@ -477,9 +477,12 @@ inline void process_find_top(struct process **cpu, struct process **mem)
                                    sizeof(struct process) * sorttmp_size);
                }
                qsort(sorttmp, i, sizeof(struct process *), comparemem);
-               for (i = 0; i < 10; i++) {
-                       mem[i] = sorttmp[i];
-
+               for (i = 0, j = 0; i < sorttmp_size && j < 10; i++) {
+                       if (j == 0 || sorttmp[i]->totalmem != mem[j-1]->totalmem
+                                       || strncmp(sorttmp[i]->name, mem[j-1]->name,128)) {
+                               mem[j++] = sorttmp[i];
+                       }
                }
        }
 }
+