aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/string.c b/string.c
index c19544deac..5c46d61605 100644
--- a/string.c
+++ b/string.c
@@ -1820,13 +1820,21 @@ hash(const unsigned char * data, int len, unsigned int h)
int
rb_memhash(const void *ptr, long len)
{
- return hash(ptr, len, 0);
+ static int hashseed_init = 0;
+ static unsigned int hashseed;
+
+ if (!hashseed_init) {
+ hashseed = rb_genrand_int32();
+ hashseed_init = 1;
+ }
+
+ return hash(ptr, len, hashseed);
}
int
rb_str_hash(VALUE str)
{
- return hash((const void *)RSTRING_PTR(str), RSTRING_LEN(str), 0);
+ return rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str));
}
int