From 16da5eb4196d553a1f95ebb884d5142eb66131d0 Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sat, 20 Jun 2009 12:47:06 +0300 Subject: [PATCH] Return unsigned and initialize index --- random.cpp | 3 ++- random.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/random.cpp b/random.cpp index 62419c4..0585078 100644 --- a/random.cpp +++ b/random.cpp @@ -11,7 +11,7 @@ #define RAND_BUF_SIZE 1024 #define RND_DEV "/dev/urandom" -int get_random(void) +unsigned int get_random(void) { static int rndbuf[RAND_BUF_SIZE]; static int index = RAND_BUF_SIZE; @@ -41,6 +41,7 @@ int get_random(void) i += ret; } while (i < RAND_BUF_SIZE * sizeof(rndbuf[0])); + index = 0; out: close(fd); } diff --git a/random.h b/random.h index f9c92c0..89507af 100644 --- a/random.h +++ b/random.h @@ -1,6 +1,6 @@ #ifndef _RANDOM_H #define _RANDOM_H -int get_random(void); +unsigned int get_random(void); #endif -- 2.44.0