void stream_destroy(stream_t *stream) { if (NULL != stream) { while(!tailq_empty(stream->rsp_q)) free(tailq_pop_head(stream->rsp_q)); if (NULL != stream->topic_patt) topic_destroy(stream->topic_patt); if (stream->have_connid) httpd_timeout_conn(stream->connid); if (NULL != stream->topicstr) free(stream->topicstr); if (NULL != stream->rsp_q) tailq_destroy(stream->rsp_q); free(stream); } }
void test_topic_init_and_destroy() { int ret; struct topic t; struct subscriber sub; ret = topic_init(&t); CU_ASSERT_EQUAL_FATAL(0, ret); // would fail if list of subscribers // was not correctly initialized ret = list_add(t.subscribers, &sub); CU_ASSERT_EQUAL_FATAL(0, ret); ret = topic_destroy(&t); CU_ASSERT_PTR_NULL_FATAL(t.name); CU_ASSERT_PTR_NULL_FATAL(t.subscribers); }