void clear_keys(void) { free_forest(builtin_cmds_root, max_modes); free_forest(user_cmds_root, max_modes); free_forest(selectors_root, max_modes); free(def_handlers); }
void vle_keys_reset(void) { free_forest(builtin_cmds_root, max_modes); free_forest(user_cmds_root, max_modes); free_forest(selectors_root, max_modes); free(def_handlers); builtin_cmds_root = NULL; selectors_root = NULL; user_cmds_root = NULL; max_modes = 0; mode_flags = NULL; def_handlers = NULL; }
void vle_keys_user_clear(void) { free_forest(user_cmds_root, max_modes); user_cmds_root = calloc(max_modes, sizeof(*user_cmds_root)); assert(user_cmds_root != NULL); }
/* do not free scene itself */ void BKE_scene_free(Scene *sce) { Base *base; base = sce->base.first; while (base) { base->object->id.us--; base = base->next; } /* do not free objects! */ if (sce->gpd) { #if 0 /* removed since this can be invalid memory when freeing everything */ /* since the grease pencil data is freed before the scene. * since grease pencil data is not (yet?), shared between objects * its probably safe not to do this, some save and reload will free this. */ sce->gpd->id.us--; #endif sce->gpd = NULL; } BLI_freelistN(&sce->base); BKE_sequencer_editing_free(sce); BKE_free_animdata((ID *)sce); BKE_keyingsets_free(&sce->keyingsets); if (sce->r.avicodecdata) { free_avicodecdata(sce->r.avicodecdata); MEM_freeN(sce->r.avicodecdata); sce->r.avicodecdata = NULL; } if (sce->r.qtcodecdata) { free_qtcodecdata(sce->r.qtcodecdata); MEM_freeN(sce->r.qtcodecdata); sce->r.qtcodecdata = NULL; } if (sce->r.ffcodecdata.properties) { IDP_FreeProperty(sce->r.ffcodecdata.properties); MEM_freeN(sce->r.ffcodecdata.properties); sce->r.ffcodecdata.properties = NULL; } BLI_freelistN(&sce->markers); BLI_freelistN(&sce->transform_spaces); BLI_freelistN(&sce->r.layers); if (sce->toolsettings) { if (sce->toolsettings->vpaint) { BKE_paint_free(&sce->toolsettings->vpaint->paint); MEM_freeN(sce->toolsettings->vpaint); } if (sce->toolsettings->wpaint) { BKE_paint_free(&sce->toolsettings->wpaint->paint); MEM_freeN(sce->toolsettings->wpaint); } if (sce->toolsettings->sculpt) { BKE_paint_free(&sce->toolsettings->sculpt->paint); MEM_freeN(sce->toolsettings->sculpt); } if (sce->toolsettings->uvsculpt) { BKE_paint_free(&sce->toolsettings->uvsculpt->paint); MEM_freeN(sce->toolsettings->uvsculpt); } BKE_paint_free(&sce->toolsettings->imapaint.paint); MEM_freeN(sce->toolsettings); sce->toolsettings = NULL; } if (sce->theDag) { free_forest(sce->theDag); MEM_freeN(sce->theDag); } if (sce->nodetree) { ntreeFreeTree(sce->nodetree); MEM_freeN(sce->nodetree); } if (sce->stats) MEM_freeN(sce->stats); if (sce->fps_info) MEM_freeN(sce->fps_info); sound_destroy_scene(sce); BKE_color_managed_view_settings_free(&sce->view_settings); }
void test() { struct forest forest; int i; FILE *forest_file = NULL; char *home = getenv("HOME"); char *forest_filename = NULL; pthread_t draw_thread; forest_filename = malloc(strlen(home) + 10); sprintf(forest_filename, "%s/.lforest", home); forest.config.nrays = 10000; forest.config.init_score = 5; forest.config.init_iterations = 1; forest.config.replace_trees = 0.125; forest.config.leaf_cost = 0.5; forest.config.branch_cost = 1.0; forest.config.re_init_chance = 0.25; forest.config.width = 640; forest.config.height = 480; forest_file = fopen(forest_filename, "rb"); if(NULL == forest_file) { forest.config.ntrees = 250; init_forest(&forest); printf("%s not found: using random trees\n", forest_filename); fflush(NULL); } else { printf("%s found: using saved trees\n", forest_filename); fflush(NULL); read_forest(forest_file, &forest); fclose(forest_file); forest_file = NULL; } /* Launch the display thread */ forest.stop = 0; pthread_create(&draw_thread, NULL, draw_forest_thread_start, (void*)&forest); for(i = 0; 0 == forest.stop; ++i) { iterate_forest(&forest); breed_forest(&forest); printf("."); fflush(NULL); } pthread_join(draw_thread, NULL); printf("%i iterations\n", i); forest_file = fopen(forest_filename, "wb"); if(NULL == forest_file) printf("Failed to open %s: not saving\n", forest_filename); else { printf("saving to %s\n", forest_filename); write_forest(forest_file, &forest); fclose(forest_file); } free_forest(&forest); free(forest_filename); }