|
|
Subscribe / Log in / New account

Single call API for the heap

Single call API for the heap

Posted Oct 31, 2024 15:56 UTC (Thu) by anton (subscriber, #25547)
In reply to: Single call API for the heap by NYKevin
Parent article: realloc() and the oversize importance of zero-size objects

I have never read anything about "good hash inputs". Normally the idea is that a good hash function distributes the inputs into the buckets like a random choice of buckets or better (perfect hashing), for inputs of any characteristics (of course each hash function has input sets that produce worst-case behaviour, but for good hash functions trivial patterns do not form such sets).

I expect that you mean that "good hash inputs" do ok even for bad hash functions. The solution to this problem is to use good hash functions, not to produce "good hash inputs" from realloc(...,0). There is no guarantee of "good hash inputs" for any other stuff that you might throw at the hash function, including other uses of realloc().


to post comments

Single call API for the heap

Posted Oct 31, 2024 17:56 UTC (Thu) by NYKevin (subscriber, #129325) [Link] (1 responses)

I suppose my real concern is that some people are going to use the modulus operator as their "hashing algorithm," under the (false) assumption that malloc(0) is required to give uniformly-distributed pointers (and because C does not come with a hash table implementation in its stdlib, so whatever hash implementation you come up with is probably not going to be a best-in-class implementation).

Single call API for the heap

Posted Nov 1, 2024 12:04 UTC (Fri) by paulj (subscriber, #341) [Link]

The Jenkins hash is easy to pull from the Linux source code, and more than good enough for non-security-sensitive, performance orientated, contexts.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds