static void test_rend_cache_entry_allocation(void *data) { (void)data; size_t ret; rend_cache_entry_t *e = NULL; // Handles a null argument ret = rend_cache_entry_allocation(NULL); tt_int_op(ret, OP_EQ, 0); // Handles a non-null argument e = tor_malloc_zero(sizeof(rend_cache_entry_t)); ret = rend_cache_entry_allocation(e); tt_int_op(ret, OP_GT, sizeof(rend_cache_entry_t)); done: tor_free(e); }
/** Helper: free storage held by a single service descriptor cache entry. */ STATIC void rend_cache_entry_free_(rend_cache_entry_t *e) { if (!e) return; rend_cache_decrement_allocation(rend_cache_entry_allocation(e)); /* We are about to remove a descriptor from the cache so remove the entry * in the failure cache. */ rend_cache_failure_remove(e->parsed); rend_service_descriptor_free(e->parsed); tor_free(e->desc); tor_free(e); }