Merge branch 'bp/post-index-change-hook'
[gitweb.git] / khash.h
diff --git a/khash.h b/khash.h
index c0da40daa78f703f825208bb7d1b4b5b3cc05ae3..532109c87f7ce190b5de3e341bafad880238ecad 100644 (file)
--- a/khash.h
+++ b/khash.h
@@ -26,6 +26,9 @@
 #ifndef __AC_KHASH_H
 #define __AC_KHASH_H
 
+#include "cache.h"
+#include "hashmap.h"
+
 #define AC_VERSION_KHASH_H "0.2.8"
 
 typedef uint32_t khint32_t;
@@ -79,11 +82,16 @@ static const double __ac_HASH_UPPER = 0.77;
        SCOPE kh_##name##_t *kh_init_##name(void) {                                                     \
                return (kh_##name##_t*)xcalloc(1, sizeof(kh_##name##_t));               \
        }                                                                                                                                       \
+       SCOPE void kh_release_##name(kh_##name##_t *h)                                          \
+       {                                                                                                                                       \
+               free(h->flags);                                                                                                 \
+               free((void *)h->keys);                                                                                  \
+               free((void *)h->vals);                                                                                  \
+       }                                                                                                                                       \
        SCOPE void kh_destroy_##name(kh_##name##_t *h)                                          \
        {                                                                                                                                       \
                if (h) {                                                                                                                \
-                       free((void *)h->keys); free(h->flags);                                  \
-                       free((void *)h->vals);                                                                          \
+                       kh_release_##name(h);                                                                           \
                        free(h);                                                                                                        \
                }                                                                                                                               \
        }                                                                                                                                       \
@@ -226,7 +234,7 @@ static const double __ac_HASH_UPPER = 0.77;
        __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
 
 #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
-       KHASH_INIT2(name, static inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
+       KHASH_INIT2(name, MAYBE_UNUSED static inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
 
 /* Other convenient macros... */