From 76c024311489ede1bca79cf647e568dde70d8a48 Mon Sep 17 00:00:00 2001 From: Nils Durner Date: Thu, 24 Sep 2009 19:19:28 +0000 Subject: [PATCH] use correct PRNG initializer --- src/include/plibc.h | 5 ++++- src/util/test_container_bloomfilter.c | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/include/plibc.h b/src/include/plibc.h index 51d78fc7e..6d02323aa 100644 --- a/src/include/plibc.h +++ b/src/include/plibc.h @@ -22,7 +22,7 @@ * @brief PlibC header * @attention This file is usually not installed under Unix, * so ship it with your application - * @version $Revision: 39 $ + * @version $Revision: 44 $ */ #ifndef _PLIBC_H_ @@ -379,6 +379,7 @@ int _win_access( const char *path, int mode ); int _win_chmod(const char *filename, int pmode); char *realpath(const char *file_name, char *resolved_name); long _win_random(void); +void _win_srandom(unsigned seed); int _win_remove(const char *path); int _win_rename(const char *oldname, const char *newname); int _win_stat(const char *path, struct stat *buffer); @@ -492,6 +493,7 @@ size_t strnlen (const char *str, size_t maxlen); #define MUNMAP(s, l) munmap(s, l) #define STRERROR(i) strerror(i) #define RANDOM() random() + #define SRANDOM(s) srandom(s) #define READLINK(p, b, s) readlink(p, b, s) #define LSTAT(p, b) lstat(p, b) #define LSTAT64(p, b) lstat64(p, b) @@ -570,6 +572,7 @@ size_t strnlen (const char *str, size_t maxlen); #define CHMOD(f, p) _win_chmod(f, p) #define PIPE(h) _win_pipe(h) #define RANDOM() _win_random() + #define SRANDOM(s) _win_srandom() #define REMOVE(p) _win_remove(p) #define RENAME(o, n) _win_rename(o, n) #define STAT(p, b) _win_stat(p, b) diff --git a/src/util/test_container_bloomfilter.c b/src/util/test_container_bloomfilter.c index 012d3f954..2e7fb2e28 100644 --- a/src/util/test_container_bloomfilter.c +++ b/src/util/test_container_bloomfilter.c @@ -69,7 +69,7 @@ main (int argc, char *argv[]) struct stat sbuf; GNUNET_log_setup ("test-container-bloomfilter", "WARNING", NULL); - srand (1); + SRANDOM (1); if (0 == stat (TESTFILE, &sbuf)) if (0 != UNLINK (TESTFILE)) GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", TESTFILE); @@ -80,7 +80,7 @@ main (int argc, char *argv[]) nextHC (&tmp); GNUNET_CONTAINER_bloomfilter_add (bf, &tmp); } - srand (1); + SRANDOM (1); ok1 = 0; for (i = 0; i < 200; i++) { @@ -108,7 +108,7 @@ main (int argc, char *argv[]) bfi = GNUNET_CONTAINER_bloomfilter_init (buf, SIZE, K); GNUNET_assert (bfi != NULL); - srand (1); + SRANDOM (1); ok1 = 0; ok2 = 0; for (i = 0; i < 200; i++) @@ -137,7 +137,7 @@ main (int argc, char *argv[]) return -1; } - srand (1); + SRANDOM (1); for (i = 0; i < 100; i++) { nextHC (&tmp); @@ -145,7 +145,7 @@ main (int argc, char *argv[]) GNUNET_CONTAINER_bloomfilter_remove (bfi, &tmp); } - srand (1); + SRANDOM (1); ok1 = 0; ok2 = 0; @@ -177,7 +177,7 @@ main (int argc, char *argv[]) return -1; } - srand (3); + SRANDOM (3); GNUNET_CONTAINER_bloomfilter_clear (bf); falseok = 0; @@ -201,14 +201,14 @@ main (int argc, char *argv[]) return -1; } - srand (2); + SRANDOM (2); i = 20; GNUNET_CONTAINER_bloomfilter_resize (bfi, &add_iterator, &i, SIZE * 2, K); - srand (2); + SRANDOM (2); i = 20; GNUNET_CONTAINER_bloomfilter_resize (bf, &add_iterator, &i, SIZE * 2, K); - srand (2); + SRANDOM (2); ok1 = 0; ok2 = 0; -- 2.25.1