diff --git a/src/test/polynomial_factorization.cpp b/src/test/polynomial_factorization.cpp index 06c67b9c2..7af0742ef 100644 --- a/src/test/polynomial_factorization.cpp +++ b/src/test/polynomial_factorization.cpp @@ -24,7 +24,8 @@ Notes: #include"polynomial_factorization.h" #endif -using namespace std; +using std::cout; +using std::endl; // some prime numbers unsigned primes[] = { diff --git a/src/util/hash.cpp b/src/util/hash.cpp index 41c4db584..bb5ca0a41 100644 --- a/src/util/hash.cpp +++ b/src/util/hash.cpp @@ -19,6 +19,13 @@ Revision History: #include"debug.h" #include"hash.h" +#include + +static unsigned read_unsigned(const char *s) { + unsigned n; + memcpy(&n, s, sizeof(unsigned)); + return n; +} // I'm using Bob Jenkin's hash function. // http://burtleburtle.net/bob/hash/doobs.html @@ -31,10 +38,11 @@ unsigned string_hash(const char * str, unsigned length, unsigned init_value) { c = init_value; /* the previous hash value */ /*---------------------------------------- handle most of the key */ + SASSERT(sizeof(unsigned) == 4); while (len >= 12) { - a += reinterpret_cast(str)[0]; - b += reinterpret_cast(str)[1]; - c += reinterpret_cast(str)[2]; + a += read_unsigned(str); + b += read_unsigned(str+4); + c += read_unsigned(str+8); mix(a,b,c); str += 12; len -= 12; }