X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fhtable%2Fhtable_type.h;h=ad3974c5e446dc74be147371d74dafb09feea631;hb=918a733fc27172f56d66a28bc24bd897ac1c48f6;hp=3b555cde4aaadd183d6e196ac50986d11fdc58d7;hpb=0c3590dc33d644f73bb8587db454c491830aaf26;p=ccan diff --git a/ccan/htable/htable_type.h b/ccan/htable/htable_type.h index 3b555cde..ad3974c5 100644 --- a/ccan/htable/htable_type.h +++ b/ccan/htable/htable_type.h @@ -20,6 +20,7 @@ * * It also defines initialization and freeing functions: * void _init(struct *); + * void _init_sized(struct *, size_t); * void _clear(struct *); * * Add function only fails if we run out of memory: @@ -38,6 +39,9 @@ * * It's currently safe to iterate over a changing hashtable, but you might * miss an element. Iteration isn't very efficient, either. + * + * You can use HTABLE_INITIALIZER like so: + * struct ht = { HTABLE_INITIALIZER(ht.raw, _hash, NULL) }; */ #define HTABLE_DEFINE_TYPE(type, keyof, hashfn, eqfn, name) \ struct name { struct htable raw; }; \ @@ -50,6 +54,10 @@ { \ htable_init(&ht->raw, name##_hash, NULL); \ } \ + static inline void name##_init_sized(struct name *ht, size_t s) \ + { \ + htable_init_sized(&ht->raw, name##_hash, NULL, s); \ + } \ static inline void name##_clear(struct name *ht) \ { \ htable_clear(&ht->raw); \