diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-26 07:10:03 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-26 07:10:03 +0000 |
commit | 05a579c9ec3526a2981f2357f7ce25d3f44e996b (patch) | |
tree | ab2f0eded10c0d9663b1eb37a1a5e468b4bdff2b /st.c | |
parent | bea5278a11deb49f8f0e32a30949a5955b12f16e (diff) | |
download | ruby-05a579c9ec3526a2981f2357f7ce25d3f44e996b.tar.gz |
Forward port r34151 from ruby_1_8_7.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@34379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -9,6 +9,7 @@ #include <stdlib.h> #endif #include <string.h> +#include <limits.h> #include "st.h" typedef struct st_table_entry st_table_entry; @@ -521,6 +522,8 @@ st_foreach(table, func, arg) return 0; } +static unsigned long hash_seed = 0; + static int strhash(string) register const char *string; @@ -550,10 +553,11 @@ strhash(string) return val + (val << 15); #else - register int val = 0; + register unsigned long val = hash_seed; while ((c = *string++) != '\0') { val = val*997 + c; + val = (val << 13) | (val >> (sizeof(st_data_t) * CHAR_BIT - 13)); } return val + (val>>5); @@ -573,3 +577,11 @@ numhash(n) { return n; } + +extern unsigned long rb_genrand_int32(void); + +void +Init_st(void) +{ + hash_seed = rb_genrand_int32(); +} |