Created attachment 23892 [details] Candidate patch, v1 Currently, apr_hash considers two keys to be equal iff memcmp(k1, k2, len) == 0. When hashing on a complex key type (e.g. a struct with a pointer field), that might not be sufficient; that is, the user might want structural equality, not the shallow equality provided by memcmp(). Attached is a straightforward patch against APR trunk that allows the user to supply a custom key comparison function when creating the hash table. I added a new constructor apr_hash_make_custom2() -- if breaking the API is acceptable, it might be cleaner to add another argument to apr_hash_make_custom() instead. The patch includes a test for the new functionality. BTW, I notice that apr_hashfunc_t takes a key of type "const char *", whereas all the other hash API functions define the type of the key as "const void *". I've used the latter, which is more sensible anyway. This inconsistency might be worth fixing for APR2. Comments welcome -- please consider this for inclusion in a future release of APR.
Any feedback on this patch? I think this is clearly useful functionality, provided there is any interest in allowing hash table keys to be non-trivial objects.