[fpc-pascal] Pointer hashing

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Tue Jan 31 18:12:22 CET 2017


On 31/01/17 15:30, Ryan Joseph wrote:
> Thanks for answering guys. Yes José is right, hashing the pointer wasn’t even a good solution so I used another hash. I had the pointers stored in another data type and I wanted to quickly test for the their entry in the table but I found another way.
>> On Jan 30, 2017, at 4:28 PM, José Mejuto <joshyfun at gmail.com> wrote:> > Hello,> > After addressing the ^ conversion showed by other people I have a question. Why you need to hash a pointer ? Hashing a value is interesting to reduce its compare time (taking collisions into account) and/or verify message integrity, and hashing a pointer does not meet none of this goals as it is process wide unique (no collisions) and its size is the fastest compare operation (most architectures).
> Regards,	Ryan Joseph

I've hashed some of the fields in a jmp_buf together so that I could do 
a quick check that a LongJmp() was being used with a sane parameter.

There's an occasional report in e.g. the Debian mailing lists where a 
project is resisting being ported to 64-bit architectures because the 
authors have mangled pointers in a size-specific way.

Historically, there's been cases where two pointers in a list node were 
xored together to save space, but it's difficult to defend that practice 
these days unless the payload is very small.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list