HT_PROTOTYPE(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
cached_getaddrinfo_item_hash,
cached_getaddrinfo_items_eq);
-HT_GENERATE(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
- cached_getaddrinfo_item_hash,
- cached_getaddrinfo_items_eq,
- 0.6, tor_malloc_, tor_realloc_, tor_free_);
+HT_GENERATE2(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
+ cached_getaddrinfo_item_hash,
+ cached_getaddrinfo_items_eq,
+ 0.6, tor_reallocarray_, tor_free_)
+ /** If true, don't try to cache getaddrinfo results. */
+ static int sandbox_getaddrinfo_cache_disabled = 0;
+
+ /** Tell the sandbox layer not to try to cache getaddrinfo results. Used as in
+ * tor-resolve, when we have no intention of initializing crypto or of
+ * installing the sandbox.*/
+ void
+ sandbox_disable_getaddrinfo_cache(void)
+ {
+ sandbox_getaddrinfo_cache_disabled = 1;
+ }
+
int
sandbox_getaddrinfo(const char *name, const char *servname,
const struct addrinfo *hints,