-#define HTABLE_DEFINE_TYPE(type, keyof, hashfn, cmpfn, name) \
-struct htable_##name; \
-struct htable_##name##_iter { struct htable_iter i; }; \
-static inline size_t htable_##name##_hash(const void *elem, void *priv) \
-{ \
- return hashfn(keyof((const type *)elem)); \
-} \
-static inline struct htable_##name *htable_##name##_new(void) \
-{ \
- return (struct htable_##name *)htable_new(htable_##name##_hash, \
- NULL); \
-} \
-static inline void htable_##name##_free(const struct htable_##name *ht) \
-{ \
- htable_free((const struct htable *)ht); \
-} \
-static inline bool htable_##name##_add(struct htable_##name *ht, \
- const type *elem) \
-{ \
- return htable_add((struct htable *)ht, hashfn(keyof(elem)), elem); \
-} \
-static inline bool htable_##name##_del(const struct htable_##name *ht, \
- const type *elem) \
-{ \
- return htable_del((struct htable *)ht, hashfn(keyof(elem)), elem); \
-} \
-static inline type *htable_##name##_get(const struct htable_##name *ht, \
- const HTABLE_KTYPE(keyof) k) \
-{ \
- /* Typecheck for cmpfn */ \
- (void)sizeof(cmpfn((const type *)NULL, \
- keyof((const type *)NULL))); \
- return (type *)htable_get((const struct htable *)ht, \
+#define HTABLE_DEFINE_TYPE(type, keyof, hashfn, eqfn, name) \
+ struct name { struct htable raw; }; \
+ struct name##_iter { struct htable_iter i; }; \
+ static inline size_t name##_hash(const void *elem, void *priv) \
+ { \
+ return hashfn(keyof((const type *)elem)); \
+ } \
+ static inline void name##_init(struct name *ht) \
+ { \
+ htable_init(&ht->raw, name##_hash, NULL); \
+ } \
+ static inline void name##_clear(struct name *ht) \
+ { \
+ htable_clear(&ht->raw); \
+ } \
+ static inline bool name##_add(struct name *ht, const type *elem) \
+ { \
+ return htable_add(&ht->raw, hashfn(keyof(elem)), elem); \
+ } \
+ static inline bool name##_del(struct name *ht, const type *elem) \
+ { \
+ return htable_del(&ht->raw, hashfn(keyof(elem)), elem); \
+ } \
+ static inline type *name##_get(const struct name *ht, \
+ const HTABLE_KTYPE(keyof) k) \
+ { \
+ /* Typecheck for eqfn */ \
+ (void)sizeof(eqfn((const type *)NULL, \
+ keyof((const type *)NULL))); \
+ return htable_get(&ht->raw, \