t5601: add more test cases for IPV6
[gitweb.git] / khash.h
diff --git a/khash.h b/khash.h
index 57ff6038c5be0fb5aa28f1b297bf6972bebab350..376475a5eaf80585311ab518d03c229a7a49a7ed 100644 (file)
--- a/khash.h
+++ b/khash.h
@@ -121,13 +121,9 @@ static const double __ac_HASH_UPPER = 0.77;
                                if (!new_flags) return -1;                                                              \
                                memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
                                if (h->n_buckets < new_n_buckets) {     /* expand */            \
-                                       khkey_t *new_keys = (khkey_t*)xrealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
-                                       if (!new_keys) return -1;                                                       \
-                                       h->keys = new_keys;                                                                     \
+                                       REALLOC_ARRAY(h->keys, new_n_buckets); \
                                        if (kh_is_map) {                                                                        \
-                                               khval_t *new_vals = (khval_t*)xrealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
-                                               if (!new_vals) return -1;                                               \
-                                               h->vals = new_vals;                                                             \
+                                               REALLOC_ARRAY(h->vals, new_n_buckets); \
                                        }                                                                                                       \
                                } /* otherwise shrink */                                                                \
                        }                                                                                                                       \
@@ -160,8 +156,8 @@ static const double __ac_HASH_UPPER = 0.77;
                                }                                                                                                               \
                        }                                                                                                                       \
                        if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
-                               h->keys = (khkey_t*)xrealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
-                               if (kh_is_map) h->vals = (khval_t*)xrealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
+                               REALLOC_ARRAY(h->keys, new_n_buckets); \
+                               if (kh_is_map) REALLOC_ARRAY(h->vals, new_n_buckets); \
                        }                                                                                                                       \
                        free(h->flags); /* free the working space */                            \
                        h->flags = new_flags;                                                                           \
@@ -320,19 +316,12 @@ static const double __ac_HASH_UPPER = 0.77;
                code;                                                                                           \
        } }
 
-static inline khint_t __kh_oid_hash(const unsigned char *oid)
-{
-       khint_t hash;
-       memcpy(&hash, oid, sizeof(hash));
-       return hash;
-}
-
 #define __kh_oid_cmp(a, b) (hashcmp(a, b) == 0)
 
-KHASH_INIT(sha1, const unsigned char *, void *, 1, __kh_oid_hash, __kh_oid_cmp)
+KHASH_INIT(sha1, const unsigned char *, void *, 1, sha1hash, __kh_oid_cmp)
 typedef kh_sha1_t khash_sha1;
 
-KHASH_INIT(sha1_pos, const unsigned char *, int, 1, __kh_oid_hash, __kh_oid_cmp)
+KHASH_INIT(sha1_pos, const unsigned char *, int, 1, sha1hash, __kh_oid_cmp)
 typedef kh_sha1_pos_t khash_sha1_pos;
 
 #endif /* __AC_KHASH_H */