apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47441] New: apr_hash: Allow custom key comparison function
Date Sat, 27 Jun 2009 20:19:05 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47441

           Summary: apr_hash: Allow custom key comparison function
           Product: APR
           Version: HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: nrc@cs.berkeley.edu


Created an attachment (id=23892)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23892)
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.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message