Re: how to hash?

From: Duane Wessels <wessels@dont-contact.us>
Date: Fri, 03 Apr 1998 23:10:56 -0700

Yee Man Chan writes:

>Why does Squid call storeInitHashValues() before it create the
>store_table?
>
>I use hash_create, hash_insert and hash_lookup to do my hash table
>transactions. Although hash_insert's return tells me my entries are
>successfully inserted, I cannot retrieve them via hash_lookup. I think I
>misunderstand the Squid's hash table facilities. Can anyone explain that
>to me?

works like this

        struct foo {
                char *key;
                void *next;
                ...
        };

        hash_table *t = hash_create(strcmp, 229, hash4);
        struct foo *F = xcalloc(1, sizeof(*F));
        F->key = xstrdup("key");
        hash_join(t, (hash_link *) F);

        ...

        struct foo *F;
        G = (struct foo *) hash_lookup(t, "key");

Duane W.

--
wessels@nlanr.net                           Think Globally, Cache Locally.
Received on Tue Jul 29 2003 - 13:15:47 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:44 MST