Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Avoid loosing meaningful bits ot pair.p2 when hashing pointer pair
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 24 Jun 2014 11:29:28 +0000 (13:29 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 24 Jun 2014 11:32:00 +0000 (13:32 +0200)
src/mc/mc_compare.cpp

index 5a7c634..6eaa3bf 100644 (file)
@@ -29,9 +29,10 @@ typedef struct s_pointers_pair {
 namespace boost {
   template<>
   struct hash<s_pointers_pair> {
 namespace boost {
   template<>
   struct hash<s_pointers_pair> {
-    typedef uint64_t result_type;
+    typedef uintptr_t result_type;
     result_type operator()(s_pointers_pair const& x) const {
     result_type operator()(s_pointers_pair const& x) const {
-      return (result_type) x.p1 ^ (result_type) x.p2 << 8;
+      return (result_type) x.p1 ^
+        ((result_type) x.p2 << 8 | (result_type) x.p2 >> (8*sizeof(uintptr_t) - 8));
     }
   };
 }
     }
   };
 }