-void exit_connections(void) {
- list_delete_list(mesh->connections);
- free_connection(everyone);
+void exit_connections(meshlink_handle_t *mesh) {
+ if(mesh->connections) {
+ list_delete_list(mesh->connections);
+ }
+
+ free_connection(mesh->everyone);
+
+ mesh->connections = NULL;
+ mesh->everyone = NULL;