From: Ben Schmidt Date: Fri, 30 Jul 2010 14:25:36 +0000 (+1000) Subject: Makes random number generation more efficient by only seeding the X-Git-Tag: RELEASE_1_2_18a1~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31d3b436bbc08e43f534f7cc58033db4634a3063;p=thirdparty%2Fmlmmj.git Makes random number generation more efficient by only seeding the generator once --- diff --git a/ChangeLog b/ChangeLog index 6a2aafe1..535072f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + o Make random number generation more efficient by only seeding the + generator once o Added feature to notify users when their posts are moderated o Fixed documentation regarding silent subscription, and added ability to silently subscribe diff --git a/src/random-int.c b/src/random-int.c index b8db32c4..de143816 100644 --- a/src/random-int.c +++ b/src/random-int.c @@ -30,10 +30,13 @@ int random_int() { + static int init = 0; unsigned int seed; int devrandom; unsigned char ch; + if (init) return rand(); + seed = (unsigned int)time(NULL); devrandom = open("/dev/urandom", O_RDONLY); @@ -53,6 +56,7 @@ int random_int() } srand(seed); + init = 1; return rand(); }