monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] Re: pointer arithmetics in C++


From: Lapo Luchini
Subject: [Monotone-devel] Re: pointer arithmetics in C++
Date: Sun, 17 Sep 2006 22:27:07 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.0 Hamster/2.0.0.1

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nathaniel Smith wrote:
> If that's really what you want, you need something like
>
> x1 ^ x2 ^ x3 ^ reinterpret_cast<int>(my_pointer);
>
> (Or perhaps multiplication would be better, or something, hash
> functions are not that easy to design.)
In fact if x1 and x2 are likely to change by 1 it would be quite easy
to have the case (x1+1 ^ x2+1 = x1 ^ x2) when the hash is a collision
(if x1 and x2 had a 0 lower bit) or similar cases.
If speed is not a real concern, it really would be better something like:
  x1*p1 + x2*p2 + x3*p3
where p1,p2,p3 are some "big" different primes.

(and me not being a cryptographer I guess it would have "other
problems" anyway, but at least it wouldn't be "weak" to such
frequently-happening use cases ^_^)

- --
Lapo Luchini
address@hidden (OpenPGP & X.509)
www.lapo.it (Jabber, ICQ, MSN)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJFDa+aAAoJELBiMTth2oCDERkP/jN3t+U0r5kIPlqp0QIp+jKk
ZOnzhqbBgB8w7zHVFNLXvbUx5w5sqq4dNn4t9VINan09QZXsqGBvLpotgFKTNnKE
g82Dtm0Qn4aok+yht4eFoGgI/8OWAfvT79ToI3RkIf0XGH6SuQBg277voSoP0uGd
dPLU4oKhau7aNpRxQvBObeZkpbO6ka2EU1bgs8j7PfdCXIdlZg9ANVbPXgv9x74A
9vAWCEn/fwcrBqlAB4qcrBVA5zv8s4mWwFDYPODlrDKdb3yEICMZnrtsjNyR8fhk
FXRFq6UW82iJC3/qBg8brX6fn2K5zzaRqJz3foV8zieasgPPFY3MTe3dCHBADb/R
AfQ1U4kR7n4euJFv9SggdjIhiuoTFaOdYR3cDwtMspBx+VWU7og3ONn4SzuAnRJv
2Elun5cOygJYxOyGJ8lJlG9lrSTjP80blwt5dE51+SyCFAerEP+4442V5PiLIvXC
o6BX/mmQjiyg+3k54sqNNy7kupjaDIwmtED0TLfu+b7xCFzUYsFA84erVQpYKACx
jL/FI6i9Fo9U0wNFjciJYqGd6gPMSZB8Gcroc/e4SOhpv0qyiV3Q2mNlnCvDrGcc
r5YHUH/oFXqbJ91WxEwdBPjGFbJnEg36MuqVFTftFvDMkfSFRq0169V3zGJ6LCzW
75+u4AEQ4ZbxWuagD4Wm
=LsRQ
-----END PGP SIGNATURE-----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]