[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: Jim Blandy <jimb_at_savonarola.red-bean.com>
Date: 2000-10-14 08:18:45 CEST

> 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);

Yes, that's what I used to think, too. It's certainly the behavior
I'd expect. But that's not what the code actually does:

    static apr_hash_entry_t **find_entry(apr_hash_t *ht,
                                        const void *key,
                                        apr_size_t klen,
                                        const void *val)
    {
        ...

        if (klen == 0)
            klen = strlen(key) + 1;

I suspect someone wanted it that way so that they could use the key
length as the number of bytes to copy... But, whatever.
Received on Sat Oct 21 14:36:11 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.