about summary refs log tree commit diff
path: root/misc/hashtable.h
diff options
context:
space:
mode:
Diffstat (limited to 'misc/hashtable.h')
-rw-r--r--misc/hashtable.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/misc/hashtable.h b/misc/hashtable.h
index 2dd227d..84a8e0b 100644
--- a/misc/hashtable.h
+++ b/misc/hashtable.h
@@ -5,28 +5,29 @@ struct htbl_iter {
     struct _htbl *tbl;
     size_t bi;
     size_t cnt;
-    void *obj;
+    struct _any *obj;
 };
 
 struct _htbl *_htbl_create(int (*equal)(const void *, const void *),
     uint32_t (*hash)(const void *), size_t keyoff, size_t chainoff);
 void _htbl_free(struct _htbl *tbl);
-void _htbl_insert(struct _htbl *tbl, void *o);
-void *_htbl_remove(struct _htbl *tbl, const void *key);
-void *_htbl_find(struct _htbl *tbl, const void *key);
-void _htbl_tov(struct _htbl *tb, void **v);
+void _htbl_insert(struct _htbl *tbl, struct _any *o);
+struct _any *_htbl_remove(struct _htbl *tbl, const void *key);
+struct _any *_htbl_find(struct _htbl *tbl, const void *key);
+void _htbl_tov(struct _htbl *tb, struct _any **v);
 size_t _htbl_size(struct _htbl *tbl);
 void _htbl_iter_init(struct _htbl *tbl, struct htbl_iter *it);
-void *_htbl_iter_next(struct htbl_iter *it);
+struct _any *_htbl_iter_next(struct htbl_iter *it);
 
-#define HTBLTYPE(name, type, ktype, kname, cname) \
+#define HTBL_ENTRY(name) struct _any *name
+
+#define HTBL_TYPE(name, type, ktype, kname, cname) \
 __attribute__((always_inline)) static inline struct name * \
-name##_create(int (*equal)(const ktype *, const ktype *), \
-    uint32_t (*hash)(const ktype *)) \
+name##_create(int (*equal)(const void *, const void *), \
+    uint32_t (*hash)(const void *)) \
 { \
     return (struct name *) \
-      _htbl_create((int (*)(const void *, const void *))equal, \
-        (uint32_t (*)(const void *))hash, offsetof(struct type, kname), \
+      _htbl_create(equal, hash, offsetof(struct type, kname), \
         offsetof(struct type, cname)); \
 } \
 \
@@ -51,12 +52,12 @@ name##_free(struct name *tbl) \
 __attribute__((always_inline)) static inline void \
 name##_insert(struct name *tbl, struct type *o) \
 { \
-    _htbl_insert((struct _htbl *)tbl, o); \
+    _htbl_insert((struct _htbl *)tbl, (struct _any *)o); \
 } \
 __attribute__((always_inline)) static inline void \
 name##_tov(struct name *tbl, struct type **v) \
 { \
-    _htbl_tov((struct _htbl *)tbl, (void **)v); \
+    _htbl_tov((struct _htbl *)tbl, (struct _any **)v); \
 } \
 \
 __attribute__((always_inline)) static inline size_t \