Browse code

fix bar calculation: releasable is part of free mention mempool in TODO

git-svn: trunk@4331

Török Edvin authored on 2008/11/04 19:40:38
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue Nov  4 13:11:24 EET 2008 (edwin)
2
+------------------------------------
3
+ * contrib/clamdtop/TODO, contrib/clamdtop/clamdtop.c: fix bar
4
+ calculation: releasable is part of free mention mempool in TODO
5
+
1 6
 Tue Nov  4 12:56:46 EET 2008 (edwin)
2 7
 ------------------------------------
3 8
  * libclamav/matcher-ac.c (cli_ac_addsig): need to use mpool allocated memory for ->str
... ...
@@ -3,3 +3,4 @@ write a manpage
3 3
 consider writing a GUI using Tk 8.5 (version 8.5 has much nicer widgets than 8.4)
4 4
 integrate into toplevel clamav, and build if ncurses is available (optional)
5 5
 figure out minimum version of ncurses required, I used 5.5 during development.
6
+show mempool statistics too.
... ...
@@ -35,6 +35,7 @@
35 35
 #include <sys/socket.h>
36 36
 #include <sys/un.h>
37 37
 #include <sys/time.h>
38
+#include <assert.h>
38 39
 
39 40
 enum colors {
40 41
 	header_color=1,
... ...
@@ -237,6 +238,7 @@ static void show_bar(WINDOW *win, size_t i, unsigned live, unsigned idle,
237 237
 	unsigned dim   = idle*(len - start - 2) / max;
238 238
 	unsigned rem = len - activ - dim - start-2;
239 239
 
240
+	assert(activ + 2 < len && activ+dim + 2 < len && activ+dim+rem + 2 < len && "Invalid values");
240 241
 	mvwaddch(win, i, start, '[' | A_BOLD);
241 242
 	wattron(win, A_BOLD | COLOR_PAIR(activ_color));
242 243
 	for(i=0;i<activ;i++)
... ...
@@ -349,7 +351,7 @@ static void output_memstats(const char* line)
349 349
 		biggest_mem = totalmem;
350 350
 		blink = 1;
351 351
 	}
352
-	show_bar(mem_window, 3, totalmem, ltotalf + lmmapu + lreleasable,
352
+	show_bar(mem_window, 3, totalmem, lmmapu + lreleasable,
353 353
 			biggest_mem, blink);
354 354
 	wrefresh(mem_window);
355 355
 }