[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hash resizing bug
From: |
Jim Meyering |
Subject: |
Re: hash resizing bug |
Date: |
Thu, 18 Jun 2009 16:40:03 +0200 |
Eric Blake wrote:
> I haven't pushed the second one to savannah yet; what do you think of it?
> Sometimes it is desirable to hash distinct pointers, in which case
> allowing a NULL user function to request this seems to make sense. My
> design choice was to provide trivial functions at initialization rather
> than penalize normal users by checking at every use of the callback
> whether the function was NULL.
Yes, I've often hashed pointer values.
However, note that the low bits of a pointer are often zero,
so that for small table sizes, this may be a very poor choice.
In applications that hash only malloc'd pointers I've used this:
size_t
hash_address (const void *addr, size_t table_size)
{
size_t k = (size_t) addr;
assert (k % 4 == 0);
return (k / 4) % table_size;
}
- Re: hash resizing bug, (continued)
- Re: hash resizing bug, Jim Meyering, 2009/06/17
- Re: hash resizing bug, Eric Blake, 2009/06/17
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/17
- Re: hash resizing bug, Eric Blake, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug,
Jim Meyering <=
- Re: hash resizing bug, Eric Blake, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Eric Blake, 2009/06/18
- hash and bitrotate (was: hash resizing bug), Eric Blake, 2009/06/18
- Re: hash and bitrotate, Eric Blake, 2009/06/18
- Re: hash and bitrotate, Jim Meyering, 2009/06/18
- Re: hash and bitrotate, Simon Josefsson, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Ben Pfaff, 2009/06/18
- another hash cleanup (was: hash resizing bug), Eric Blake, 2009/06/18