diff --git a/src/common/container.c b/src/common/container.c index 5facd72d65a5fe13ebe0acf1e8abfecaf0f1b221..6dae0bb9322cf8199d2d94cdc6509d6640843311 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -675,7 +675,7 @@ strmap_new(void) { strmap_t *result; result = tor_malloc(sizeof(strmap_t)); - HT_INIT(&result->head); + HT_INIT(strmap_impl, &result->head); return result; } @@ -686,7 +686,7 @@ digestmap_new(void) { digestmap_t *result; result = tor_malloc(sizeof(digestmap_t)); - HT_INIT(&result->head); + HT_INIT(digestmap_impl, &result->head); return result; } diff --git a/src/common/ht.h b/src/common/ht.h index d51d7c5c00236b9d542b47522c98bdedd8c060a5..11b61ed3413f0e690c7b55e7bc4c4e2843a944ac 100644 --- a/src/common/ht.h +++ b/src/common/ht.h @@ -26,14 +26,6 @@ #define HT_INITIALIZER() \ { NULL, 0, 0, 0, -1 } -#define HT_INIT(root) do { \ - (root)->hth_table_length = 0; \ - (root)->hth_table = NULL; \ - (root)->hth_n_entries = 0; \ - (root)->hth_load_limit = 0; \ - (root)->hth_prime_idx = -1; \ - } while (0) - #define HT_ENTRY(type) \ struct { \ struct type *hte_next; \ @@ -59,7 +51,7 @@ #define HT_NEXT(name, head, elm) name##_HT_NEXT((head), (elm)) #define HT_NEXT_RMV(name, head, elm) name##_HT_NEXT_RMV((head), (elm)) #define HT_CLEAR(name, head) name##_HT_CLEAR(head) - +#define HT_INIT(name, head) name##_HT_INIT(head) /* Helper: */ static INLINE unsigned ht_improve_hash(unsigned h) @@ -100,6 +92,14 @@ ht_string_hash(const char *s) int name##_HT_GROW(struct name *ht, unsigned min_capacity); \ void name##_HT_CLEAR(struct name *ht); \ int _##name##_HT_REP_IS_BAD(struct name *ht); \ + static INLINE void \ + name##_HT_INIT(struct name *head) { \ + head->hth_table_length = 0; \ + head->hth_table = NULL; \ + head->hth_n_entries = 0; \ + head->hth_load_limit = 0; \ + head->hth_prime_idx = -1; \ + } \ /* Helper: returns a pointer to the right location in the table \ * 'head' to find or insert the element 'elm'. */ \ static INLINE struct type ** \ @@ -344,7 +344,7 @@ ht_string_hash(const char *s) if (head->hth_table) \ freefn(head->hth_table); \ head->hth_table_length = 0; \ - HT_INIT(head); \ + name##_HT_INIT(head); \ } \ /* Debugging helper: return false iff the representation of 'head' is \ * internally consistent. */ \ diff --git a/src/or/dns.c b/src/or/dns.c index 60dca8b692e98c0e23b63919e760ae51b557e5d2..4a9853959e0191eedce16ead6d315a87c6f57b7e 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -162,7 +162,7 @@ HT_GENERATE(cache_map, cached_resolve_t, node, cached_resolve_hash, static void init_cache_map(void) { - HT_INIT(&cache_root); + HT_INIT(cache_map, &cache_root); } #ifdef USE_EVENTDNS