diff options
-rw-r--r-- | lout/object.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lout/object.cc b/lout/object.cc index 08ea0452..a081f023 100644 --- a/lout/object.cc +++ b/lout/object.cc @@ -124,16 +124,22 @@ int Pointer::hashValue() * return ((int*)value)[0] ^ ((int*)value)[1]; */ #if SIZEOF_VOID_P == 4 + // Assuming that sizeof(void*) == sizeof(int); on 32 bit systems. return (int)value; #else - return ((int*)value)[0] ^ ((int*)value)[1]; + // Assuming that sizeof(void*) == 2 * sizeof(int); on 64 bit + // systems (int is still 32 bit). + // Combine both parts of the pointer value *itself*, not what it + // points to, by first referencing it (operator "&"), then + // dereferencing it again (operator "[]"). + return ((int*)&value)[0] ^ ((int*)&value)[1]; #endif } void Pointer::intoStringBuffer(misc::StringBuffer *sb) { char buf[64]; - snprintf(buf, sizeof(buf), "0x%p", value); + snprintf(buf, sizeof(buf), "%p", value); sb->append(buf); } |