Index: client/civclient.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v retrieving revision 1.133 diff -u -r1.133 civclient.c --- client/civclient.c 2002/06/02 18:22:49 1.133 +++ client/civclient.c 2002/06/05 19:30:37 @@ -582,10 +582,10 @@ popdown_all_city_dialogs(); close_all_diplomacy_dialogs(); client_remove_all_cli_conn(); - game_remove_all_players(); set_unit_focus_no_center(NULL); clear_notify_window(); - idex_init(); /* clear old data */ + game_free(); + game_init(); } update_menus(); } Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.237 diff -u -r1.237 packhand.c --- client/packhand.c 2002/06/01 18:55:03 1.237 +++ client/packhand.c 2002/06/05 19:30:39 @@ -424,7 +424,8 @@ init_worklist(&pcity->worklist); /* Initialise list of improvements with city/building wide equiv_range. */ - improvement_status_init(pcity->improvements); + improvement_status_init(pcity->improvements, + ARRAY_SIZE(pcity->improvements)); /* Initialise city's vector of improvement effects. */ ceff_vector_init(&pcity->effects); @@ -602,7 +603,8 @@ if (city_is_new) { /* Initialise list of improvements with city/building wide equiv_range. */ - improvement_status_init(pcity->improvements); + improvement_status_init(pcity->improvements, + ARRAY_SIZE(pcity->improvements)); /* Initialise city's vector of improvement effects. */ ceff_vector_init(&pcity->effects); @@ -1105,7 +1107,8 @@ game.nuclearwinter=pinfo->nuclearwinter; game.cooling=pinfo->cooling; if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) { - improvement_status_init(game.improvements); + improvement_status_init(game.improvements, + ARRAY_SIZE(game.improvements)); /* Free vector of effects with a worldwide range. */ geff_vector_free(&game.effects); @@ -1660,14 +1663,10 @@ void handle_ruleset_control(struct packet_ruleset_control *packet) { int i; - - for(i=0; iruler_titles); - free(get_government(i)->helptext); - } - free(governments); - governments = NULL; - + + tilespec_free_city_tiles(game.styles_count); + ruleset_data_free(); + game.aqueduct_size = packet->aqueduct_size; game.sewer_size = packet->sewer_size; game.add_to_size_limit = packet->add_to_size_limit; @@ -1684,7 +1683,6 @@ freelog(LOG_DEBUG, "techl %d: %d", i, game.rtech.partisan_req[i]); } - game.government_count = packet->government_count; game.government_when_anarchy = packet->government_when_anarchy; game.default_government = packet->default_government; @@ -1692,21 +1690,12 @@ game.num_impr_types = packet->num_impr_types; game.num_tech_types = packet->num_tech_types; - governments = fc_calloc(game.government_count, sizeof(struct government)); - for(i=0; iruler_titles = NULL; - get_government(i)->helptext = NULL; - } + governments_alloc(packet->government_count); - free_nations(game.nation_count); - game.nation_count = packet->nation_count; - alloc_nations(game.nation_count); + nations_alloc(packet->nation_count); game.playable_nation_count = packet->playable_nation_count; - tilespec_free_city_tiles(game.styles_count); - free(city_styles); - game.styles_count = packet->style_count; - city_styles = fc_calloc( game.styles_count, sizeof(struct citystyle) ); + city_styles_alloc(packet->style_count); tilespec_alloc_city_tiles(game.styles_count); } @@ -1755,7 +1744,6 @@ u->paratroopers_mr_req = p->paratroopers_mr_req; u->paratroopers_mr_sub = p->paratroopers_mr_sub; - free(u->helptext); u->helptext = p->helptext; /* pointer assignment */ tilespec_setup_unit_type(p->id); @@ -1782,7 +1770,6 @@ a->preset_cost = p->preset_cost; a->num_reqs = p->num_reqs; - free(a->helptext); a->helptext = p->helptext; /* pointer assignment */ } @@ -1804,24 +1791,18 @@ sz_strlcpy(b->name, p->name); b->tech_req = p->tech_req; b->bldg_req = p->bldg_req; - free(b->terr_gate); b->terr_gate = p->terr_gate; /* pointer assignment */ - free(b->spec_gate); b->spec_gate = p->spec_gate; /* pointer assignment */ b->equiv_range = p->equiv_range; - free(b->equiv_dupl); b->equiv_dupl = p->equiv_dupl; /* pointer assignment */ - free(b->equiv_repl); b->equiv_repl = p->equiv_repl; /* pointer assignment */ b->obsolete_by = p->obsolete_by; b->is_wonder = p->is_wonder; b->build_cost = p->build_cost; b->upkeep = p->upkeep; b->sabotage = p->sabotage; - free(b->effect); b->effect = p->effect; /* pointer assignment */ b->variant = p->variant; /* FIXME: remove when gen-impr obsoletes */ - free(b->helptext); b->helptext = p->helptext; /* pointer assignment */ sz_strlcpy(b->soundtag, p->soundtag); sz_strlcpy(b->soundtag_alt, p->soundtag_alt); @@ -2092,7 +2073,6 @@ t->transform_result = p->transform_result; t->transform_time = p->transform_time; - free(t->helptext); t->helptext = p->helptext; /* pointer assignment */ tilespec_setup_tile_type(p->id); Index: common/city.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.c,v retrieving revision 1.159 diff -u -r1.159 city.c --- common/city.c 2002/05/28 22:39:10 1.159 +++ common/city.c 2002/06/05 19:30:41 @@ -22,6 +22,7 @@ #include "government.h" #include "log.h" #include "map.h" +#include "mem.h" #include "support.h" #include "city.h" @@ -2229,4 +2230,23 @@ bool is_city_option_set(struct city *pcity, enum city_options option) { return TEST_BIT(pcity->city_options, option); +} + +/************************************************************************** + Allocate memory for this amount of city styles. +**************************************************************************/ +void city_styles_alloc(int num) +{ + city_styles = fc_calloc(num, sizeof(struct citystyle)); + game.styles_count = num; +} + +/************************************************************************** + De-allocate the memory used by the city styles. +**************************************************************************/ +void city_styles_free(void) +{ + free(city_styles); + city_styles = NULL; + game.styles_count = 0; } Index: common/city.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.h,v retrieving revision 1.107 diff -u -r1.107 city.h --- common/city.h 2002/05/08 06:07:53 1.107 +++ common/city.h 2002/06/05 19:30:41 @@ -453,6 +453,8 @@ /* misc */ bool is_city_option_set(struct city *pcity, enum city_options option); +void city_styles_alloc(int num); +void city_styles_free(void); /* * Iterates over all improvements which are built in the given city. Index: common/game.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/game.c,v retrieving revision 1.140 diff -u -r1.140 game.c --- common/game.c 2002/05/23 15:09:26 1.140 +++ common/game.c 2002/06/05 19:30:42 @@ -738,14 +738,14 @@ game.load_options.load_starts = TRUE; game.load_options.load_private_map = TRUE; game.load_options.load_settings = TRUE; - + map_init(); idex_init(); conn_list_init(&game.all_connections); conn_list_init(&game.est_connections); conn_list_init(&game.game_connections); - + for(i=0; iisland_improv=(Impr_Status *)fc_realloc(plr->island_improv, (maxcont+1)*game.num_impr_types); for (i=oldmax+1;i<=maxcont;i++) { - improvement_status_init(&plr->island_improv[i*game.num_impr_types]); + improvement_status_init(&plr->island_improv[i * game.num_impr_types], + game.num_impr_types); } /* Next, do the island-wide effects. */ Index: common/game.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/game.h,v retrieving revision 1.105 diff -u -r1.105 game.h --- common/game.h 2002/04/30 12:52:54 1.105 +++ common/game.h 2002/06/05 19:30:42 @@ -222,6 +222,9 @@ }; void game_init(void); +void game_free(void); +void ruleset_data_free(void); + int game_next_year(int); void game_advance_year(void); Index: common/government.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/government.c,v retrieving revision 1.32 diff -u -r1.32 government.c --- common/government.c 2002/03/21 05:17:21 1.32 +++ common/government.c 2002/06/05 19:30:42 @@ -267,3 +267,39 @@ sz_strlcpy(title->male_title, male); sz_strlcpy(title->female_title, female); } + +/*************************************************************** + Allocate space for the given number of governments. +***************************************************************/ +void governments_alloc(int num) +{ + governments = fc_calloc(num, sizeof(struct government)); + game.government_count = num; +} + +/*************************************************************** + De-allocate resources associated with the given government. +***************************************************************/ +void government_free(struct government *gov) +{ + free(gov->ruler_titles); + gov->ruler_titles = NULL; + + free(gov->helptext); + gov->helptext = NULL; +} + +/*************************************************************** + De-allocate the currently allocated governments. +***************************************************************/ +void governments_free(void) +{ + int i; + + for (i = 0; i < game.government_count; i++) { + government_free(get_government(i)); + } + free(governments); + governments = NULL; + game.government_count = 0; +} Index: common/government.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/government.h,v retrieving revision 1.19 diff -u -r1.19 government.h --- common/government.h 2002/02/19 16:41:23 1.19 +++ common/government.h 2002/06/05 19:30:42 @@ -186,5 +186,8 @@ void set_ruler_title(struct government *gov, int nation, char *male, char *female); +void governments_alloc(int num); +void government_free(struct government *gov); +void governments_free(void); #endif /* FC__GOVERNMENT_H */ Index: common/idex.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/idex.c,v retrieving revision 1.7 diff -u -r1.7 idex.c --- common/idex.c 2002/02/12 04:49:52 1.7 +++ common/idex.c 2002/06/05 19:30:42 @@ -28,6 +28,7 @@ unless IDEX_DIE set. ***************************************************************************/ +#include #include #include "city.h" @@ -50,20 +51,26 @@ /************************************************************************** Initialize. Should call this at the start before use. - May also call later, to re-initialize (eg, client disconnects). ***************************************************************************/ void idex_init(void) { - if (idex_city_hash) { - hash_free(idex_city_hash); - idex_city_hash = NULL; - } - if (idex_unit_hash) { - hash_free(idex_unit_hash); - idex_unit_hash = NULL; - } + assert(idex_city_hash == NULL); + assert(idex_unit_hash == NULL); + idex_city_hash = hash_new(hash_fval_int, hash_fcmp_int); idex_unit_hash = hash_new(hash_fval_int, hash_fcmp_int); +} + +/************************************************************************** + Free the hashs. +***************************************************************************/ +void idex_free(void) +{ + hash_free(idex_city_hash); + idex_city_hash = NULL; + + hash_free(idex_unit_hash); + idex_unit_hash = NULL; } /************************************************************************** Index: common/idex.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/idex.h,v retrieving revision 1.1 diff -u -r1.1 idex.h --- common/idex.h 2000/04/30 13:15:40 1.1 +++ common/idex.h 2002/06/05 19:30:42 @@ -22,6 +22,7 @@ struct unit; void idex_init(void); +void idex_free(void); void idex_register_city(struct city *pcity); void idex_register_unit(struct unit *punit); Index: common/improvement.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/improvement.c,v retrieving revision 1.20 diff -u -r1.20 improvement.c --- common/improvement.c 2002/03/06 03:03:13 1.20 +++ common/improvement.c 2002/06/05 19:30:43 @@ -197,6 +197,42 @@ } /************************************************************************** + Frees the memory associated with this improvement. +**************************************************************************/ +void improvement_free(Impr_Type_id id) +{ + struct impr_type *p = get_improvement_type(id); + + free(p->terr_gate); + p->terr_gate = NULL; + + free(p->spec_gate); + p->spec_gate = NULL; + + free(p->equiv_dupl); + p->equiv_dupl = NULL; + + free(p->equiv_repl); + p->equiv_repl = NULL; + + free(p->effect); + p->effect = NULL; + + free(p->helptext); + p->helptext = NULL; +} + +/*************************************************************** + Frees the memory associated with all improvements. +***************************************************************/ +void improvements_free() +{ + impr_type_iterate(impr) { + improvement_free(impr); + } impr_type_iterate_end; +} + +/************************************************************************** Returns 1 if the improvement_type "exists" in this game, 0 otherwise. An improvement_type doesn't exist if one of: - id is out of range; @@ -379,11 +415,17 @@ /************************************************************************** Clears a list of improvements - sets them all to I_NONE **************************************************************************/ -void improvement_status_init(Impr_Status *improvements) +void improvement_status_init(Impr_Status * improvements, size_t elements) { - impr_type_iterate(i) { + /* + * Since this function is called with elements!=game.num_impr_types + * impr_type_iterate can't used here. + */ + Impr_Type_id i; + + for (i = 0; i < elements; i++) { improvements[i] = I_NONE; - } impr_type_iterate_end; + } } /************************************************************************** Index: common/improvement.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v retrieving revision 1.10 diff -u -r1.10 improvement.h --- common/improvement.h 2002/04/18 09:59:16 1.10 +++ common/improvement.h 2002/06/05 19:30:43 @@ -271,6 +271,8 @@ /* improvement functions */ +void improvement_free(Impr_Type_id id); +void improvements_free(void); struct impr_type *get_improvement_type(Impr_Type_id id); bool improvement_exists(Impr_Type_id id); int improvement_value(Impr_Type_id id); @@ -283,7 +285,7 @@ bool wonder_obsolete(Impr_Type_id id); bool is_wonder_useful(Impr_Type_id id); Impr_Type_id find_improvement_by_name(char *s); -void improvement_status_init(Impr_Status *improvements); +void improvement_status_init(Impr_Status * improvements, size_t elements); /* player related improvement and unit functions */ Index: common/map.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.c,v retrieving revision 1.119 diff -u -r1.119 map.c --- common/map.c 2002/02/27 08:19:02 1.119 +++ common/map.c 2002/06/05 19:30:44 @@ -205,22 +205,37 @@ /************************************************************************** Allocate space for map, and initialise the tiles. Uses current map.xsize and map.ysize. - Uses fc_realloc, in case map was allocated before (eg, in client); - should have called map_init() (via game_init()) before this, - so map.tiles will be 0 on first call. **************************************************************************/ void map_allocate(void) { freelog(LOG_DEBUG, "map_allocate (was %p) (%d,%d)", map.tiles, map.xsize, map.ysize); - - map.tiles = fc_realloc(map.tiles, map.xsize*map.ysize*sizeof(struct tile)); + + assert(map.tiles == NULL); + map.tiles = fc_malloc(map.xsize * map.ysize * sizeof(struct tile)); whole_map_iterate(x, y) { tile_init(map_get_tile(x, y)); } whole_map_iterate_end; } +/*************************************************************** + Frees the allocated memory of the map. +***************************************************************/ +void map_free(void) +{ + if (map.tiles) { + /* it is possible that map_init was called but not map_allocate */ + + whole_map_iterate(x, y) { + tile_free(map_get_tile(x, y)); + } + whole_map_iterate_end; + free(map.tiles); + map.tiles = NULL; + } +} + /*************************************************************** ... ***************************************************************/ @@ -1139,6 +1154,14 @@ /*************************************************************** ... ***************************************************************/ +void tile_free(struct tile *ptile) +{ + unit_list_unlink_all(&ptile->units); +} + +/*************************************************************** +... +***************************************************************/ struct tile *map_get_tile(int x, int y) { return MAP_TILE(x, y); @@ -1480,4 +1503,27 @@ map_distance_vector(&diff_x, &diff_y, start_x, start_y, end_x, end_y); return (diff_x == 0) || (diff_y == 0); +} + +/************************************************************************** + Free memory which is associated with this terrain type. +**************************************************************************/ +void tile_type_free(enum tile_terrain_type type) +{ + struct tile_type *p = get_tile_type(type); + + free(p->helptext); + p->helptext = NULL; +} + +/************************************************************************** + Free memory which is associated with terrain types. +**************************************************************************/ +void tile_types_free(void) +{ + enum tile_terrain_type i; + + for (i = T_FIRST; i < T_COUNT; i++) { + tile_type_free(i); + } } Index: common/map.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.h,v retrieving revision 1.125 diff -u -r1.125 map.h --- common/map.h 2002/02/27 10:33:08 1.125 +++ common/map.h 2002/06/05 19:30:44 @@ -183,6 +183,7 @@ bool map_is_empty(void); void map_init(void); void map_allocate(void); +void map_free(void); char *map_get_tile_info_text(int x, int y); char *map_get_tile_fpt_text(int x, int y); @@ -267,6 +268,7 @@ void map_set_special(int x, int y, enum tile_special_type spe); void map_clear_special(int x, int y, enum tile_special_type spe); void tile_init(struct tile *ptile); +void tile_free(struct tile *ptile); bool is_real_tile(int x, int y); bool is_normal_map_pos(int x, int y); @@ -306,6 +308,8 @@ bool is_move_cardinal(int start_x, int start_y, int end_x, int end_y); int map_move_cost(struct unit *punit, int x, int y); struct tile_type *get_tile_type(enum tile_terrain_type type); +void tile_type_free(enum tile_terrain_type type); +void tile_types_free(void); enum tile_terrain_type get_terrain_by_name(char * name); char *get_terrain_name(enum tile_terrain_type type); enum tile_special_type get_special_by_name(char * name); Index: common/nation.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/nation.c,v retrieving revision 1.22 diff -u -r1.22 nation.c --- common/nation.c 2002/04/30 12:52:54 1.22 +++ common/nation.c 2002/06/05 19:30:44 @@ -162,35 +162,55 @@ /*************************************************************** Allocate space for the given number of nations. ***************************************************************/ -void alloc_nations(int num) +void nations_alloc(int num) { nations = (struct nation_type *)fc_calloc(num, sizeof(struct nation_type)); + game.nation_count = num; } /*************************************************************** De-allocate the currently allocated nations. ***************************************************************/ -void free_nations(int num) +void nations_free() { - int i, j; + Nation_Type_id nation; - if(!nations) return; - for( i = 0; i < num; i++) { - for( j = 0; j < nations[i].leader_count; j++) { - free( nations[i].leader_name[j] ); - } - if (nations[i].city_names) { - /* Unfortunately, this monstrosity of a loop is necessary given the - setup of city_names. But that setup does make things simpler - elsewhere. */ - for (j = 0; nations[i].city_names[j].name; j++) { - free(nations[i].city_names[j].name); - } - free(nations[i].city_names); - } + if (!nations) { + return; + } + + for (nation = 0; nation < game.nation_count; nation++) { + nation_free(nation); } + free(nations); nations = NULL; + game.nation_count = 0; +} + +/*************************************************************** + De-allocate resources associated with the given nation. +***************************************************************/ +void nation_free(Nation_Type_id nation) +{ + int i; + struct nation_type *p = get_nation_by_idx(nation); + + for (i = 0; i < p->leader_count; i++) { + free(p->leader_name[i]); + } + + if (p->city_names) { + /* + * Unfortunately, this monstrosity of a loop is necessary given + * the setup of city_names. But that setup does make things + * simpler elsewhere. + */ + for (i = 0; p->city_names[i].name; i++) { + free(p->city_names[i].name); + } + free(p->city_names); + } } /*************************************************************** Index: common/nation.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/nation.h,v retrieving revision 1.13 diff -u -r1.13 nation.h --- common/nation.h 2002/04/30 12:52:54 1.13 +++ common/nation.h 2002/06/05 19:30:44 @@ -97,8 +97,9 @@ struct nation_type *get_nation_by_plr(struct player *plr); struct nation_type *get_nation_by_idx(Nation_Type_id nation); bool check_nation_leader_name(Nation_Type_id nation, const char *name); -void alloc_nations(int num); -void free_nations(int num); +void nations_alloc(int num); +void nations_free(void); +void nation_free(Nation_Type_id nation); int get_nation_city_style(Nation_Type_id nation); #endif /* FC__NATION_H */ Index: common/player.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.c,v retrieving revision 1.96 diff -u -r1.96 player.c --- common/player.c 2002/06/01 19:25:25 1.96 +++ common/player.c 2002/06/05 19:30:48 @@ -103,7 +103,7 @@ plr->really_gives_vision = 0; /* Initialise list of improvements with Player-wide equiv_range */ - improvement_status_init(plr->improvements); + improvement_status_init(plr->improvements, ARRAY_SIZE(plr->improvements)); /* Initialise vector of effects with player range. */ geff_vector_init(&plr->effects); @@ -134,7 +134,8 @@ plr->island_improv=fc_calloc((numcont+1)*game.num_impr_types, sizeof(Impr_Status)); for (i=0; i<=numcont; i++) { - improvement_status_init(&plr->island_improv[i*game.num_impr_types]); + improvement_status_init(&plr->island_improv[i * game.num_impr_types], + game.num_impr_types); } /* Initialise lists of island-range effects. */ Index: common/tech.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v retrieving revision 1.47 diff -u -r1.47 tech.c --- common/tech.c 2002/03/05 19:13:45 1.47 +++ common/tech.c 2002/06/05 19:30:48 @@ -557,3 +557,31 @@ || game.rgame.tech_cost_style == 2) && game.rgame.tech_leakage == 0); } + +/*************************************************************** + De-allocate resources associated with the given tech. +***************************************************************/ +void tech_free(Tech_Type_id tech) +{ + struct advance *p = &advances[tech]; + + free(p->helptext); + p->helptext = NULL; + + if (p->bonus_message) { + free(p->bonus_message); + p->bonus_message = NULL; + } +} + +/*************************************************************** + De-allocate resources of all techs. +***************************************************************/ +void techs_free(void) +{ + Tech_Type_id i; + + for (i = A_FIRST; i < game.num_tech_types; i++) { + tech_free(i); + } +} Index: common/tech.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v retrieving revision 1.32 diff -u -r1.32 tech.h --- common/tech.h 2002/02/14 15:17:20 1.32 +++ common/tech.h 2002/06/05 19:30:48 @@ -115,6 +115,9 @@ void precalc_tech_data(void); +void tech_free(Tech_Type_id tech); +void techs_free(void); + extern struct advance advances[]; #endif /* FC__TECH_H */ Index: common/unittype.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v retrieving revision 1.16 diff -u -r1.16 unittype.c --- common/unittype.c 2002/03/18 01:49:40 1.16 +++ common/unittype.c 2002/06/05 19:30:48 @@ -561,3 +561,24 @@ } return U_LAST; } + +/************************************************************************** + Frees the memory associated with this unit type. +**************************************************************************/ +void unit_type_free(Unit_Type_id id) +{ + struct unit_type *p = get_unit_type(id); + + free(p->helptext); + p->helptext = NULL; +} + +/*************************************************************** + Frees the memory associated with all unit types. +***************************************************************/ +void unit_types_free(void) +{ + unit_type_iterate(i) { + unit_type_free(i); + } unit_type_iterate_end; +} Index: common/unittype.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v retrieving revision 1.12 diff -u -r1.12 unittype.h --- common/unittype.h 2002/04/18 09:59:17 1.12 +++ common/unittype.h 2002/06/05 19:30:49 @@ -235,6 +235,9 @@ Unit_Type_id get_role_unit(int role, int index); Unit_Type_id best_role_unit(struct city *pcity, int role); +void unit_type_free(Unit_Type_id id); +void unit_types_free(void); + #define unit_type_iterate(m_i) \ { \ Unit_Type_id m_i; \ Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.181 diff -u -r1.181 citytools.c --- server/citytools.c 2002/04/30 12:52:57 1.181 +++ server/citytools.c 2002/06/05 19:30:50 @@ -1034,7 +1034,8 @@ init_worklist(&pcity->worklist); /* Initialise list of improvements with City- and Building-wide equiv_range */ - improvement_status_init(pcity->improvements); + improvement_status_init(pcity->improvements, + ARRAY_SIZE(pcity->improvements)); /* Initialise city's vector of improvement effects. */ ceff_vector_init(&pcity->effects); Index: server/gamehand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v retrieving revision 1.111 diff -u -r1.111 gamehand.c --- server/gamehand.c 2002/04/25 14:09:37 1.111 +++ server/gamehand.c 2002/06/05 19:30:50 @@ -143,7 +143,7 @@ } /* Initialise list of improvements with world-wide equiv_range */ - improvement_status_init(game.improvements); + improvement_status_init(game.improvements, ARRAY_SIZE(game.improvements)); /* Free vector of effects with world-wide range. */ geff_vector_free(&game.effects); Index: server/ruleset.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v retrieving revision 1.109 diff -u -r1.109 ruleset.c --- server/ruleset.c 2002/05/14 19:40:41 1.109 +++ server/ruleset.c 2002/06/05 19:30:52 @@ -1463,8 +1463,7 @@ nval, G_MAGIC, filename); exit(EXIT_FAILURE); } - game.government_count = nval; - governments = fc_calloc(game.government_count, sizeof(struct government)); + governments_alloc(nval); /* first fill in government names so find_government_by_name will work -SKi */ for(i = 0; i < game.government_count; i++) { @@ -1811,7 +1810,7 @@ MAX_NUM_NATIONS - 1, game.playable_nation_count); game.playable_nation_count = MAX_NUM_NATIONS - 1; } - alloc_nations(game.nation_count); + nations_alloc(game.nation_count); for( i=0; iimprovements); + improvement_status_init(pcity->improvements, + ARRAY_SIZE(pcity->improvements)); /* Initialise city's vector of improvement effects. */ ceff_vector_init(&pcity->effects); @@ -1938,7 +1939,8 @@ if (!game.is_new_game) { /* If new game, this is done in srv_main.c */ /* Initialise lists of improvements with World and Island equiv_ranges */ - improvement_status_init(game.improvements); + improvement_status_init(game.improvements, + ARRAY_SIZE(game.improvements)); /* Blank vector of effects with world-wide range. */ geff_vector_free(&game.effects); Index: server/srv_main.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v retrieving revision 1.82 diff -u -r1.82 srv_main.c --- server/srv_main.c 2002/05/25 17:44:09 1.82 +++ server/srv_main.c 2002/06/05 19:30:55 @@ -1979,5 +1979,5 @@ } close_connections_and_socket(); - free_rulesets(); + game_free(); }