From eaa737fecd57fff0950f616a63a421d1f82d4c61 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Thu, 21 Mar 2013 21:23:34 +0800 Subject: [PATCH] Make sure "struct timeval" is initialised on OS X to avoid valgrind warnings --- random.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/random.c b/random.c index 1a75fbf..0378e9a 100644 --- a/random.c +++ b/random.c @@ -217,6 +217,9 @@ void seedrandom() { pid = getpid(); sha1_process(&hs, (void*)&pid, sizeof(pid)); + // gettimeofday() doesn't completely fill out struct timeval on + // OS X (10.8.3), avoid valgrind warnings by clearing it first + memset(&tv, 0x0, sizeof(tv)); gettimeofday(&tv, NULL); sha1_process(&hs, (void*)&tv, sizeof(tv));