int main(int argc, char* argv[]) { gtk_init (&argc, &argv); MainWindow* main_window = main_window_new(); // Declaring Level and cpSpace structures Level* l; cpSpace* physics_world; // function that returns a filename depending on the level number selected char* file_name = level_file_name(main_window->level_number); // These functions allocate space and initializes the Level structure // and passes the structure to the World for the world to be initialized l = level_new(file_name); physics_world = world_physics_new(l); World* world = game_view_get_world(main_window_get_game_view(main_window)); world_physics_add_box(physics_world, .5, .5, .1, .1, 0); world_load_space(world, physics_world); main_window_begin(main_window); // This function frees memory allocated for the Level structure and the sub-structures // contained within it level_destroy(l); return EXIT_SUCCESS; }
void wid_game_map_client_wid_destroy (void) { if (client_level) { LOG("Client: Destroy game level"); level_destroy(&client_level, false /* keep players */); } if (wid_game_map_client_window) { LOG("Client: Destroy game window"); wid_player_info_hide(true /* fast */); wid_player_inventory_hide(true /* fast */); wid_player_action_hide(true /* fast */, true /* player quit */); wid_destroy(&wid_game_map_client_window); } if (wid_scoreline_container_top) { wid_destroy(&wid_scoreline_container_top); } if (wid_scoreline_container_bot) { wid_destroy(&wid_scoreline_container_bot); } }
void poldiff_destroy(poldiff_t ** diff) { if (!diff || !(*diff)) return; apol_policy_destroy(&(*diff)->orig_pol); apol_policy_destroy(&(*diff)->mod_pol); apol_bst_destroy(&(*diff)->class_bst); apol_bst_destroy(&(*diff)->perm_bst); apol_bst_destroy(&(*diff)->bool_bst); type_map_destroy(&(*diff)->type_map); attrib_summary_destroy(&(*diff)->attrib_diffs); poldiff_avrule_destroy(&(*diff)->avrule_diffs[AVRULE_OFFSET_ALLOW]); poldiff_avrule_destroy(&(*diff)->avrule_diffs[AVRULE_OFFSET_AUDITALLOW]); poldiff_avrule_destroy(&(*diff)->avrule_diffs[AVRULE_OFFSET_DONTAUDIT]); poldiff_avrule_destroy(&(*diff)->avrule_diffs[AVRULE_OFFSET_NEVERALLOW]); bool_destroy(&(*diff)->bool_diffs); cat_destroy(&(*diff)->cat_diffs); class_destroy(&(*diff)->class_diffs); common_destroy(&(*diff)->common_diffs); level_destroy(&(*diff)->level_diffs); range_trans_destroy(&(*diff)->range_trans_diffs); role_destroy(&(*diff)->role_diffs); role_allow_destroy(&(*diff)->role_allow_diffs); role_trans_destroy(&(*diff)->role_trans_diffs); user_destroy(&(*diff)->user_diffs); terule_destroy(&(*diff)->terule_diffs[TERULE_OFFSET_CHANGE]); terule_destroy(&(*diff)->terule_diffs[TERULE_OFFSET_MEMBER]); terule_destroy(&(*diff)->terule_diffs[TERULE_OFFSET_TRANS]); type_summary_destroy(&(*diff)->type_diffs); free(*diff); *diff = NULL; }
poldiff_level_summary_t *level_create(void) { poldiff_level_summary_t *ls = calloc(1, sizeof(poldiff_level_summary_t)); if (ls == NULL) return NULL; if ((ls->diffs = apol_vector_create(level_free)) == NULL) { level_destroy(&ls); return NULL; } return ls; }
/* Done with a game structure: */ void game_free(GameData *gd) { if(!gd) return; if(gd->is_active) { /* Debug if we need to: */ if(gd->is_debug) level_dump_bmp(gd->data.active.lvl, "debug_end.bmp"); drawbuffer_destroy(gd->data.active.b); plist_destroy (gd->data.active.pl); tanklist_destroy (gd->data.active.tl); level_destroy (gd->data.active.lvl); screen_destroy (gd->data.active.s); } free_mem(gd); }
int level_reset(poldiff_t * diff) { int error = 0; if (diff == NULL) { ERR(diff, "%s", strerror(EINVAL)); errno = EINVAL; return -1; } level_destroy(&diff->level_diffs); diff->level_diffs = level_create(); if (diff->level_diffs == NULL) { error = errno; ERR(diff, "%s", strerror(error)); errno = error; return -1; } return 0; }
TreeCommunicator::~TreeCommunicator() { level_destroy(); comm_destroy(); mpi_type_destroy(); }