void layout_remove_node (void *layout, tp_node *node) { pthread_mutex_lock (&mutex); tp_layout *l = (tp_layout*)layout; tp_particle *particle = node->particle; box_remove_particle (l->box, particle); particle_free (particle); dict_remove_element (l->nodes, node->name); pthread_mutex_unlock (&mutex); }
void do_garbage_collect(world_t*w){ int i = 0; particle_t *p = NULL; while(i < w->max_particles){ p = w->all_particle[i]; if(p && particle_is_dead(p)){ particle_free(p); w->all_particle[i] = NULL; } i++; } }
void star_destruction(int level) { int i, j; int icell, idelete, ipart, ipart_next; int num_level_cells; int *level_cells; double dt_eff; if(sf_feedback_particle->destroy_star_particle == NULL) return; #ifdef STAR_PARTICLE_TYPES /* this ifdef is not strictly necessary */ start_time( WORK_TIMER ); select_level( level, CELL_TYPE_LOCAL | CELL_TYPE_LEAF, &num_level_cells, &level_cells ); #pragma omp parallel for default(none), private(icell,ipart,ipart_next,idelete), shared(num_level_cells,level_cells,cell_particle_list,particle_level,level,particle_id,star_particle_type,particle_species_indices,num_particle_species,particle_list_next, particle_list_prev, sf_feedback_particle), schedule(dynamic) for ( i = 0; i < num_level_cells; i++ ) { icell = level_cells[i]; ipart = cell_particle_list[icell]; while ( ipart != NULL_PARTICLE ) { ipart_next = particle_list_next[ipart]; if ( particle_is_star(ipart) ) { idelete = sf_feedback_particle->destroy_star_particle(level,icell,ipart); cart_assert(idelete==0 || idelete==1); if(idelete == 1) { #pragma omp critical { /* delete_particle should be threadsafe, but just to be sure */ delete_particle(icell,ipart); particle_free(ipart); } } } ipart = ipart_next; } } cart_free(level_cells); end_time( WORK_TIMER ); #endif /* STAR_PARTICLE_TYPES */ }
void scene_free(scene_t *scene) { int i; glDisable(GL_LIGHT0); glDisable(GL_LIGHT1); glDisable(GL_LIGHT2); glDisable(GL_LIGHT3); glDisable(GL_LIGHT4); glDisable(GL_LIGHT5); glDisable(GL_LIGHT6); glDisable(GL_LIGHT7); if(scene->land) land_free(scene->land); if(scene->camera) camera_free(scene->camera); if(scene->pathpos) spline_free(scene->pathpos); if(scene->pathdir) spline_free(scene->pathdir); if(scene->sky) sky_free(scene->sky); if(scene->sun) sky_sun_free(scene->sun); if(scene->pathsun) spline_free(scene->pathsun); for(i = 0; i < scene->num_mesh; i++) thing_mesh_free(scene->mesh[i]); if(scene->mesh) free(scene->mesh); for(i = 0; i < scene->num_thing; i++) thing_free(scene->thing[i]); if(scene->thing) free(scene->thing); for(i = 0; i < scene->num_animation; i++) { thing_free(scene->animation[i]->thing); if(scene->animation[i]->path) spline_free(scene->animation[i]->path); free(scene->animation[i]); } if(scene->animation) free(scene->animation); for(i = 0; i < scene->num_particle; i++) { particle_free(scene->particle[i]->particle); if(scene->particle[i]->path) spline_free(scene->particle[i]->path); free(scene->particle[i]); } if(scene->particle) free(scene->particle); for(i = 0; i < scene->num_dynamiclight; i++) { dynamiclight_free(scene->dynamiclight[i]->light); if(scene->dynamiclight[i]->path) spline_free(scene->dynamiclight[i]->path); free(scene->dynamiclight[i]); } if(scene->dynamiclight) free(scene->dynamiclight); free(scene); }
void layout_move_node (void *layout, tp_node *node, tp_point point) { pthread_mutex_lock (&mutex); tp_layout *l = (tp_layout*)layout; //remove current particle box_remove_particle (l->box, node->particle); particle_free (node->particle); node_set_particle (node, NULL); //add new particle at point tp_particle *particle = particle_new (node->name, l, l->box, node); particle->position = point; box_add_particle (l->box, particle); node_set_particle (node, particle); //particle is now frozen (it might be moving) ((tp_particle*)(node->particle))->frozen = 1; layout_reset_energies (l); pthread_mutex_unlock (&mutex); }