[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: APR hash tables, restated

From: Greg Stein <gstein_at_lyra.org>
Date: 2000-10-13 23:56:42 CEST

On Fri, Oct 13, 2000 at 03:52:25PM -0500, Jim Blandy wrote:
> Here's a simpler restatement of my concern about null keys:
> I'd like to use APR hash tables to hash arbitrary binary objects. For
> example, in the filesystem, I use APR hash tables for a node cache,
> which is indexed by node ID's; a node ID is an array of integers. If
> you can see that it's handy to take arbitrary objects and hash on
> them, then you can certainly imagine that some of these objects might have
> the empty byte string as a valid entity.
> But at the moment, APR hash tables can't distinguish between the empty
> byte string and the byte string containing one zero byte. They're
> both treated as equivalent keys. It's kind of screwey.

Untrue. These two statements are different:

  apr_hash_get(ht, "", 0);
  apr_hash_get(ht, "", 1);

The former is a zero-length key, the latter is a length of 1 containing a
the value zero.

Think about how the key and length are handled:

    if (len == 0)
        len = strlen(key);

What I plan to do is introduce -1 to mean "compute the strlen for me" rather
than using 0 to do that (since we want 0 to be a legal key length).


Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:11 2006

This is an archived mail posted to the Subversion Dev mailing list.