summaryrefslogtreecommitdiff
path: root/tables
diff options
context:
space:
mode:
authorBojan Smojver <bojan@apache.org>2012-01-16 08:20:56 +0000
committerBojan Smojver <bojan@apache.org>2012-01-16 08:20:56 +0000
commitf501180dc0e583f45f855741c5b64d3c0a8ef796 (patch)
tree1bd29789cb35f9713da7509fd5653fa94644c84c /tables
parent50544f1d1370bf5624f87436d98d853d54693fd4 (diff)
downloadapr-f501180dc0e583f45f855741c5b64d3c0a8ef796.tar.gz
Do not use srand()/rand() to randomise hashes. Use just "random" data instead.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1231858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables')
-rw-r--r--tables/apr_hash.c7
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;