aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/wmmemfree/files/patch-wmmemfree.c
blob: 0193cc03bea50830fd83f18ca1dae16e1a120657 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--- wmmemfree.c.orig	2003-03-21 20:47:14 UTC
+++ wmmemfree.c
@@ -27,15 +27,18 @@
 #include "draw.h"
 #include "options.h"
 
+void mem_init();
+
 int    argc;
 char **argv;
 int    exitloop = 0;
+volatile sig_atomic_t need_update = 0;
 
 void handle_timer(int sig)
 {
  if(sig == SIGALRM)
  {
-  draw_window();
+  need_update = 1;
  }
 }
 
@@ -45,8 +48,8 @@ void start_timer()
 
  tv.it_value.tv_sec = 2; /* give 2 seconds for safety */
  tv.it_value.tv_usec = 0;
- tv.it_interval.tv_sec = 0;
- tv.it_interval.tv_usec = opt_milisecs * 1000;
+ tv.it_interval.tv_sec = opt_milisecs / 1000;
+ tv.it_interval.tv_usec = (opt_milisecs % 1000) * 1000;
  signal(SIGALRM, handle_timer);
  setitimer(ITIMER_REAL, &tv, NULL);
 }
@@ -69,9 +72,15 @@ int main(int carg, char **varg)
  argv = varg;
  parse_args();
  make_window();
+ mem_init();
  start_timer();
  while(!exitloop)
  {
+  if(need_update)
+  {
+   draw_window();
+   need_update = 0;
+  }
   process_events();
  }
  stop_timer();