[ovs-dev] [PATCH] timeval: Hide "memory leak" from Valgrind.

Ben Pfaff blp at nicira.com
Thu Jun 24 11:35:27 PDT 2010

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 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/timeval.c b/lib/timeval.c
index f3e6583..c69799d 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -141,7 +141,7 @@ time_enable_restart(void)
 static void
-    timer_t timer_id;
+    static timer_t timer_id;    /* "static" to avoid apparent memory leak. */
     struct itimerspec itimer;

More information about the dev mailing list