diff options
author | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2012-01-16 08:20:56 +0000 |
---|---|---|
committer | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2012-01-16 08:20:56 +0000 |
commit | ad9bd104a54a81cbebb4bd5aab914e81904d1333 (patch) | |
tree | 1bd29789cb35f9713da7509fd5653fa94644c84c /tables/apr_hash.c | |
parent | da44f7cf5eff7726040c891ad39834d019c6fce4 (diff) | |
download | libapr-ad9bd104a54a81cbebb4bd5aab914e81904d1333.tar.gz |
Do not use srand()/rand() to randomise hashes. Use just "random" data instead.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1231858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables/apr_hash.c')
-rw-r--r-- | tables/apr_hash.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/tables/apr_hash.c b/tables/apr_hash.c index f899d5156..013e2e1af 100644 --- a/tables/apr_hash.c +++ b/tables/apr_hash.c @@ -19,9 +19,6 @@ #include "apr_general.h" #include "apr_pools.h" #include "apr_time.h" -#if APR_HAVE_STDLIB_H -#include <stdlib.h> /* for rand, srand */ -#endif #include "apr_hash.h" @@ -106,8 +103,8 @@ APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool) ht->free = NULL; ht->count = 0; ht->max = INITIAL_MAX; - srand((unsigned int)((now >> 32) ^ now ^ (apr_uintptr_t)ht)); - ht->seed = (unsigned int)(rand()); + ht->seed = (unsigned int)((now >> 32) ^ now ^ (apr_uintptr_t)pool ^ + (apr_uintptr_t)ht ^ (apr_uintptr_t)&now) - 1; ht->array = alloc_array(ht, ht->max); ht->hash_func = NULL; |