timeval: Hide "memory leak" from Valgrind.
authorBen Pfaff <blp@nicira.com>
Thu, 24 Jun 2010 18:35:27 +0000 (11:35 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 25 Jun 2010 20:28:34 +0000 (13:28 -0700)
In glibc, "timer_t" is a "void *" that appears to point into malloc()'d
memory.  By throwing it away entirely, we leak it, which makes valgrind
complain.  We really don't ever care to use the timer object again, but
we can't destroy it without stopping the periodic timer.  So make it
static to avoid a warning from Valgrind.

lib/timeval.c

index f3e65837ff0bd9d75eeba7cfa5202cd87d1643a1..c69799d080db6cbb420c378a539b023ff9385f1c 100644 (file)
@@ -141,7 +141,7 @@ time_enable_restart(void)
 static void
 set_up_timer(void)
 {
-    timer_t timer_id;
+    static timer_t timer_id;    /* "static" to avoid apparent memory leak. */
     struct itimerspec itimer;
 
     set_up_monotonic();