/** Constructor to create a new empty map from digests to void*'s. */ digestmap_t * digestmap_new(void) { digestmap_t *result; result = tor_malloc(sizeof(digestmap_t)); HT_INIT(digestmap_impl, &result->head); return result; }
/** Constructor to create a new empty map from strings to void*'s. */ strmap_t * strmap_new(void) { strmap_t *result; result = tor_malloc(sizeof(strmap_t)); HT_INIT(strmap_impl, &result->head); return result; }
/* Public function: Initialize the global HS circuitmap. */ void hs_circuitmap_init(void) { tor_assert(!the_hs_circuitmap); the_hs_circuitmap = tor_malloc_zero(sizeof(struct hs_circuitmap_ht)); HT_INIT(hs_circuitmap_ht, the_hs_circuitmap); }
/** Create an empty nodelist if we haven't done so already. */ static void init_nodelist(void) { if (PREDICT_UNLIKELY(the_nodelist == NULL)) { the_nodelist = tor_malloc_zero(sizeof(nodelist_t)); HT_INIT(nodelist_map, &the_nodelist->nodes_by_id); the_nodelist->nodes = smartlist_new(); } }
fp_pair_map_t * fp_pair_map_new(void) { fp_pair_map_t *result; result = tor_malloc(sizeof(fp_pair_map_t)); HT_INIT(fp_pair_map_impl, &result->head); return result; }
/** Return a pointer to the microdescriptor cache, creating (but not loading) * it if necessary. */ static microdesc_cache_t * get_microdesc_cache_noload(void) { if (PREDICT_UNLIKELY(the_microdesc_cache==NULL)) { microdesc_cache_t *cache = tor_malloc_zero(sizeof(*cache)); HT_INIT(microdesc_map, &cache->map); cache->cache_fname = get_datadir_fname("cached-microdescs"); cache->journal_fname = get_datadir_fname("cached-microdescs.new"); the_microdesc_cache = cache; } return the_microdesc_cache; }
/*---------------------------------------------------------------------------*/ void sessions_cache_construct(void) { HT_INIT(&sessions_cache, xio_int32_hash, xio_int32_cmp, xio_int32_cp); spin_lock_init(&ss_lock); }