summaryrefslogtreecommitdiff
path: root/lout
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2013-01-07 12:53:16 +0100
committerSebastian Geerken <devnull@localhost>2013-01-07 12:53:16 +0100
commit44a8af5732ee316dfccf2f6c10d0b17bb3f4a633 (patch)
tree0b318f38949db8431083fb0fc671dadaf64006d8 /lout
parentf655191659c9c8bd3648ad49d9a8115f91229712 (diff)
Fixing a bug (and another glitch) in Pointer.
Diffstat (limited to 'lout')
-rw-r--r--lout/object.cc10
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);
}