diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-12-05 16:42:48 +1030 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-12-05 16:42:48 +1030 |
commit | e1374049678842f5086f174d97ae916345686f87 (patch) | |
tree | e00cc49a635530c28c5d03d1cc4ca060ab57c2e9 /lib/ccan/htable/htable.c | |
parent | 0ac7deefbf190e11d38cc47807e0f5f6cfb1775e (diff) | |
download | samba-e1374049678842f5086f174d97ae916345686f87.tar.gz samba-e1374049678842f5086f174d97ae916345686f87.tar.bz2 samba-e1374049678842f5086f174d97ae916345686f87.zip |
lib/ccan/htable: HTABLE_INITIALIZER() for static initialization.
Unfortunately it's a bit of a pain to use for typed hashtables, but it
works.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 60cc720d0797fc49325437ea36a9ffd909c75ed0)
Diffstat (limited to 'lib/ccan/htable/htable.c')
-rw-r--r-- | lib/ccan/htable/htable.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/ccan/htable/htable.c b/lib/ccan/htable/htable.c index f3e529211d..0a01ead897 100644 --- a/lib/ccan/htable/htable.c +++ b/lib/ccan/htable/htable.c @@ -45,18 +45,10 @@ static inline uintptr_t get_hash_ptr_bits(const struct htable *ht, void htable_init(struct htable *ht, size_t (*rehash)(const void *elem, void *priv), void *priv) { - ht->bits = 0; + struct htable empty = HTABLE_INITIALIZER(empty, NULL, NULL); + *ht = empty; ht->rehash = rehash; ht->priv = priv; - ht->elems = 0; - ht->deleted = 0; - ht->max = 0; - ht->max_with_deleted = 0; - /* This guarantees we enter update_common first add. */ - ht->common_mask = -1; - ht->common_bits = 0; - ht->perfect_bit = 0; - /* Dummy table until first insert. */ ht->table = &ht->perfect_bit; } |