X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fhtable%2Fhtable.h;h=03193567d847a5512b31d173bcb8a21a6d54d09e;hb=4ad5144790a12523f8a7c24c469a34907b6942a6;hp=ed668e7405ed84e819cec49b85f8186b85287933;hpb=60cc720d0797fc49325437ea36a9ffd909c75ed0;p=ccan diff --git a/ccan/htable/htable.h b/ccan/htable/htable.h index ed668e74..03193567 100644 --- a/ccan/htable/htable.h +++ b/ccan/htable/htable.h @@ -51,6 +51,21 @@ struct htable { void htable_init(struct htable *ht, size_t (*rehash)(const void *elem, void *priv), void *priv); +/** + * htable_init_sized - initialize an empty hash table of given size. + * @ht: the hash table to initialize + * @rehash: hash function to use for rehashing. + * @priv: private argument to @rehash function. + * @size: the number of element. + * + * If this returns false, @ht is still usable, but may need to do reallocation + * upon an add. If this returns true, it will not need to reallocate within + * @size htable_adds. + */ +bool htable_init_sized(struct htable *ht, + size_t (*rehash)(const void *elem, void *priv), + void *priv, size_t size); + /** * htable_clear - empty a hash table. * @ht: the hash table to clear