You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bo...@apache.org on 2012/01/16 09:20:57 UTC

svn commit: r1231858 - /apr/apr/trunk/tables/apr_hash.c

Author: bojan
Date: Mon Jan 16 08:20:56 2012
New Revision: 1231858

URL: http://svn.apache.org/viewvc?rev=1231858&view=rev
Log:
Do no use srand()/rand() to randomise hashes. Use just "random" data instead.

Modified:
    apr/apr/trunk/tables/apr_hash.c

Modified: apr/apr/trunk/tables/apr_hash.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_hash.c?rev=1231858&r1=1231857&r2=1231858&view=diff
==============================================================================
--- apr/apr/trunk/tables/apr_hash.c (original)
+++ apr/apr/trunk/tables/apr_hash.c Mon Jan 16 08:20:56 2012
@@ -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(
     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;