void jnx_btree_destroy(jnx_btree* tree) { JNXCHECK(tree); if ( tree == NULL ) { return; } delete_node_and_subtrees(tree->root); jnx_thread_mutex_destroy(&tree->internal_lock); free(tree); }
void discovery_service_cleanup(discovery_service **ppsvc) { discovery_service *svc = *ppsvc; JNXCHECK(svc); if (svc->isrunning) { discovery_service_stop(svc); } jnx_thread_mutex_destroy(&svc->update_time_lock); peerstore_destroy(&(svc->peers)); free(svc); *ppsvc = 0; }
void jnx_hash_destroy(jnx_hashmap** hash) { jnx_hashmap *hashmap = *hash; JNXCHECK(hashmap); jnx_int32 len = hashmap->size; jnx_int32 count; for(count = 0; count < len; ++count) { jnx_hash_element *current_element = &hashmap->data[count]; if(current_element->used) { jnx_list *current_bucket = current_element->bucket; while(current_bucket->head) { jnx_hash_bucket_el *current_element = current_bucket->head->_data; free(current_element->origin_key); free(current_element); current_bucket->head = current_bucket->head->next_node; } jnx_list_destroy(¤t_bucket); } } jnx_thread_mutex_destroy(&hashmap->internal_lock); free(hashmap); *hash = NULL; }