void host_table_finalize( ) { assert(hosttable); HostData *it; unsigned i; const void *key; tmq_destroy(timeout_queue); timeout_queue = NULL; for (it = hash_first(hosttable, &i, &key); it; it = hash_next(hosttable, &i, &key)) host_remove((HostKey*)key); hash_destroy(hosttable); }
END_TEST /** Test Case for TMQ Insert Single Element */ START_TEST(test_tmq_insert_one) { struct tmq *tmq; struct tmq_element *elem; int key = 100; tmq = tmq_create (); elem = tmq_element_create (&key, sizeof(key)); tmq_insert (tmq, elem); fail_unless ((tmq->size == 1), "Insert one test failed"); tmq_destroy (tmq); }
END_TEST /** Test Case for TMQ Insert a Bunch of Elements */ START_TEST(test_tmq_insert_a_bunch) { struct tmq *tmq = tmq_create (); struct tmq_element *elem; int key; for (key = 0; key < 9000; key++) { elem = tmq_element_create (&key, sizeof(key)); tmq_insert (tmq, elem); } fail_unless ((tmq->size == 9000), "Insert a bunch test failed"); tmq_destroy (tmq); }
/* Destroy Frag Table * * Will destroy the entire tree, and destory each of the fragment lists + * fragments in the tree. * * @return -1 on failure * 0 on success */ int frag_table_finalize() { struct frag_list *it; unsigned i; const void *key; if(!fragtable) return -1; #ifdef ENABLE_PTHREADS tmq_stop(timeout_queue); #endif tmq_destroy(timeout_queue); for(it = hash_first(fragtable, &i, &key); it; it = hash_next(fragtable, &i, &key)) frag_table_remove((struct frag_key *) key, it); hash_destroy(fragtable); return 0; }