}
void exit_configuration(splay_tree_t **config_tree) {
- splay_delete_tree(*config_tree);
+ if(*config_tree)
+ splay_delete_tree(*config_tree);
*config_tree = NULL;
}
}
void exit_connections(meshlink_handle_t *mesh) {
- list_delete_list(mesh->connections);
+ if(mesh->connections)
+ list_delete_list(mesh->connections);
+
free_connection(mesh->everyone);
+
+ mesh->connections = NULL;
+ mesh->everyone = NULL;
}
connection_t *new_connection(void) {
}
void exit_edges(meshlink_handle_t *mesh) {
- splay_delete_tree(mesh->edges);
+ if(mesh->edges)
+ splay_delete_tree(mesh->edges);
+ mesh->edges = NULL;
}
/* Creation and deletion of connection elements */
close all open network connections
*/
void close_network_connections(meshlink_handle_t *mesh) {
- for(list_node_t *node = mesh->connections->head, *next; node; node = next) {
- next = node->next;
- connection_t *c = node->data;
- c->outgoing = NULL;
- terminate_connection(mesh, c, false);
+ if(mesh->connections) {
+ for(list_node_t *node = mesh->connections->head, *next; node; node = next) {
+ next = node->next;
+ connection_t *c = node->data;
+ c->outgoing = NULL;
+ terminate_connection(mesh, c, false);
+ }
}
if(mesh->outgoings)
void exit_nodes(meshlink_handle_t *mesh) {
pthread_mutex_lock(&(mesh->nodes_mutex));
- hash_free(mesh->node_udp_cache);
- splay_delete_tree(mesh->nodes);
+ if(mesh->node_udp_cache)
+ hash_free(mesh->node_udp_cache);
+ if(mesh->nodes)
+ splay_delete_tree(mesh->nodes);
+ mesh->node_udp_cache = NULL;
+ mesh->nodes = NULL;
pthread_mutex_unlock(&(mesh->nodes_mutex));
}
}
void exit_requests(meshlink_handle_t *mesh) {
- splay_delete_tree(mesh->past_request_tree);
+ if(mesh->past_request_tree)
+ splay_delete_tree(mesh->past_request_tree);
+ mesh->past_request_tree = NULL;
timeout_del(&mesh->loop, &mesh->past_request_timeout);
}