]> git.ozlabs.org Git - ccan/blobdiff - ccan/htable/htable_type.h
htable: add htable_count().
[ccan] / ccan / htable / htable_type.h
index 14011676903807fed252318ef5884b55f14e9556..9dad4b3927186ab661f6099eeb7e801ed9204277 100644 (file)
@@ -25,6 +25,9 @@
  *     void <name>_clear(struct <name> *);
  *     bool <name>_copy(struct <name> *dst, const struct <name> *src);
  *
+ * Count entries:
+ *     size_t <name>_count(const struct <name> *ht);
+ *
  * Add function only fails if we run out of memory:
  *     bool <name>_add(struct <name> *ht, const <type> *e);
  *
        {                                                               \
                return htable_init_sized(&ht->raw, name##_hash, NULL, s); \
        }                                                               \
+       static inline UNNEEDED size_t name##_count(const struct name *ht) \
+       {                                                               \
+               return htable_count(&ht->raw);                          \
+       }                                                               \
        static inline UNNEEDED void name##_clear(struct name *ht)       \
        {                                                               \
                htable_clear(&ht->raw);                                 \