1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Clean up bogosities in use of random(3) and srandom(3) --- do not assume

that RAND_MAX applies to them, since it doesn't.  Instead add a
config.h parameter MAX_RANDOM_VALUE.  This is currently set at 2^31-1
but could be auto-configured if that ever proves necessary.  Also fix
some outright bugs like calling srand() where srandom() is appropriate.
This commit is contained in:
Tom Lane
2000-08-07 00:51:42 +00:00
parent 259489bab7
commit 9426047021
8 changed files with 47 additions and 25 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: geqo_main.c,v 1.22 2000/06/28 03:31:45 tgl Exp $
* $Id: geqo_main.c,v 1.23 2000/08/07 00:51:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -106,9 +106,9 @@ geqo(Query *root)
/* seed random number generator */
/* XXX why is this done every time around? */
if (Geqo_random_seed >= 0)
srandom(Geqo_random_seed);
srandom((unsigned int) Geqo_random_seed);
else
srandom(time(NULL));
srandom((unsigned int) time(NULL));
/* allocate genetic pool memory */
pool = alloc_pool(pool_size, number_of_rels);