2004-12-23 13:58:39 +01:00
|
|
|
#include "free.h"
|
2005-07-01 22:51:46 +02:00
|
|
|
#include "lg_commentary_struct.h"
|
2005-06-05 12:39:29 +02:00
|
|
|
#include "transfer.h"
|
2005-03-03 13:46:48 +01:00
|
|
|
#include "user.h"
|
2004-12-30 17:48:19 +01:00
|
|
|
#include "variables.h"
|
2004-12-23 13:58:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Free all memory allocated by the program.
|
|
|
|
This mainly means we have to free a lot of GStrings
|
|
|
|
and GArrays. */
|
|
|
|
void
|
|
|
|
free_memory(void)
|
|
|
|
{
|
2004-12-30 17:48:19 +01:00
|
|
|
free_variables();
|
2005-06-01 20:19:02 +02:00
|
|
|
free_names(FALSE);
|
2005-05-16 09:09:53 +02:00
|
|
|
free_transfer_list();
|
2005-04-06 10:49:55 +02:00
|
|
|
free_country(FALSE);
|
2005-04-04 12:36:04 +02:00
|
|
|
free_users(FALSE);
|
2005-01-09 21:21:22 +01:00
|
|
|
free_live_game(&live_game_temp);
|
2005-07-01 22:51:46 +02:00
|
|
|
free_lg_commentary(FALSE);
|
2005-04-04 12:36:04 +02:00
|
|
|
free_support_dirs();
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
2005-05-16 09:09:53 +02:00
|
|
|
/** Free the transfer list. */
|
|
|
|
void
|
|
|
|
free_transfer_list(void)
|
|
|
|
{
|
2005-05-17 08:15:05 +02:00
|
|
|
gint i;
|
2005-05-16 09:09:53 +02:00
|
|
|
|
|
|
|
for(i=0;i<transfer_list->len;i++)
|
|
|
|
g_array_free(g_array_index(transfer_list, Transfer, i).offers, TRUE);
|
|
|
|
|
|
|
|
free_g_array(&transfer_list);
|
|
|
|
}
|
|
|
|
|
2005-05-01 12:16:14 +02:00
|
|
|
/** Free the memory occupied by the season stats. */
|
|
|
|
void
|
2005-05-02 16:39:30 +02:00
|
|
|
free_season_stats(gboolean reset)
|
2005-05-01 12:16:14 +02:00
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
|
2005-05-02 16:39:30 +02:00
|
|
|
if(season_stats == NULL)
|
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-05-01 12:16:14 +02:00
|
|
|
for(i=0;i<season_stats->len;i++)
|
|
|
|
{
|
|
|
|
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_stats->len;j++)
|
|
|
|
free_league_stats(
|
|
|
|
&g_array_index(g_array_index(season_stats, SeasonStat, i).league_stats,
|
|
|
|
LeagueStat, j));
|
|
|
|
|
|
|
|
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_champs->len;j++)
|
|
|
|
{
|
|
|
|
g_string_free(
|
|
|
|
g_array_index(
|
|
|
|
g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).cl_name, TRUE);
|
|
|
|
g_string_free(
|
|
|
|
g_array_index(
|
|
|
|
g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).team_name, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(j=0;j<g_array_index(season_stats, SeasonStat, i).cup_champs->len;j++)
|
|
|
|
{
|
|
|
|
g_string_free(
|
|
|
|
g_array_index(
|
|
|
|
g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).cl_name, TRUE);
|
|
|
|
g_string_free(
|
|
|
|
g_array_index(
|
|
|
|
g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).team_name, TRUE);
|
|
|
|
}
|
2005-05-16 09:09:53 +02:00
|
|
|
|
|
|
|
g_array_free(g_array_index(season_stats, SeasonStat, i).cup_champs, TRUE);
|
|
|
|
g_array_free(g_array_index(season_stats, SeasonStat, i).league_champs, TRUE);
|
2005-05-01 12:16:14 +02:00
|
|
|
}
|
|
|
|
|
2005-05-02 16:39:30 +02:00
|
|
|
free_g_array(&season_stats);
|
|
|
|
|
|
|
|
if(reset)
|
|
|
|
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
|
2005-05-01 12:16:14 +02:00
|
|
|
}
|
|
|
|
|
2005-03-03 13:46:48 +01:00
|
|
|
/** Free the users array. */
|
|
|
|
void
|
2005-04-04 12:36:04 +02:00
|
|
|
free_users(gboolean reset)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if(users == NULL)
|
2005-04-04 12:36:04 +02:00
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
users = g_array_new(FALSE, FALSE, sizeof(User));
|
2005-03-03 13:46:48 +01:00
|
|
|
return;
|
2005-04-04 12:36:04 +02:00
|
|
|
}
|
2005-03-03 13:46:48 +01:00
|
|
|
|
|
|
|
for(i=0;i<users->len;i++)
|
|
|
|
free_user(&usr(i));
|
|
|
|
|
|
|
|
free_g_array(&users);
|
2005-04-04 12:36:04 +02:00
|
|
|
|
|
|
|
if(reset)
|
|
|
|
users = g_array_new(FALSE, FALSE, sizeof(User));
|
2005-03-03 13:46:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Free the memory the user occupies.
|
|
|
|
@param user The user we free. */
|
|
|
|
void
|
|
|
|
free_user(User *user)
|
|
|
|
{
|
2005-03-18 23:03:23 +01:00
|
|
|
gint i;
|
|
|
|
|
2005-03-03 13:46:48 +01:00
|
|
|
free_g_string(&user->name);
|
2005-06-20 14:46:57 +02:00
|
|
|
free_g_string(&user->sponsor.name);
|
2005-03-03 13:46:48 +01:00
|
|
|
free_live_game(&user->live_game);
|
2005-03-24 08:42:24 +01:00
|
|
|
free_option_list(&user->options, FALSE);
|
2005-03-18 23:03:23 +01:00
|
|
|
|
|
|
|
for(i=0;i<user->events->len;i++)
|
|
|
|
free_event(&g_array_index(user->events, Event, i));
|
|
|
|
|
|
|
|
free_g_array(&user->events);
|
2005-04-16 09:46:04 +02:00
|
|
|
|
|
|
|
for(i=0;i<user->history->len;i++)
|
|
|
|
g_string_free(g_array_index(user->history,
|
|
|
|
UserHistory, i).value_string, TRUE);
|
|
|
|
free_g_array(&user->history);
|
2005-07-08 11:26:00 +02:00
|
|
|
|
|
|
|
free_player_array(&user->youth_academy.players);
|
2005-03-18 23:03:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Free a user event. */
|
|
|
|
void
|
|
|
|
free_event(Event *event)
|
|
|
|
{
|
2005-03-19 21:04:08 +01:00
|
|
|
free_g_string(&event->value_string);
|
2005-03-03 13:46:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Free an array of options.
|
|
|
|
@param array The array we free.
|
|
|
|
@param reset Whether to create the array anew (empty).
|
|
|
|
@see #Option */
|
|
|
|
void
|
2005-03-24 08:42:24 +01:00
|
|
|
free_option_list(OptionList *optionlist, gboolean reset)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
2005-03-24 08:42:24 +01:00
|
|
|
if(optionlist->list == NULL)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
|
|
|
if(reset)
|
2005-03-24 08:42:24 +01:00
|
|
|
{
|
|
|
|
optionlist->list = g_array_new(FALSE, FALSE, sizeof(Option));
|
|
|
|
g_datalist_init(&optionlist->datalist);
|
|
|
|
}
|
2005-03-03 13:46:48 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-24 08:42:24 +01:00
|
|
|
for(i=0;i<optionlist->list->len;i++)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
2005-03-24 08:42:24 +01:00
|
|
|
free_g_string(&g_array_index(optionlist->list, Option, i).name);
|
|
|
|
free_g_string(&g_array_index(optionlist->list, Option, i).string_value);
|
2005-03-03 13:46:48 +01:00
|
|
|
}
|
|
|
|
|
2005-03-24 08:42:24 +01:00
|
|
|
free_g_array(&optionlist->list);
|
2005-03-03 13:46:48 +01:00
|
|
|
|
|
|
|
if(reset)
|
2005-03-24 08:42:24 +01:00
|
|
|
{
|
|
|
|
optionlist->list = g_array_new(FALSE, FALSE, sizeof(Option));
|
|
|
|
g_datalist_init(&optionlist->datalist);
|
|
|
|
}
|
2005-03-03 13:46:48 +01:00
|
|
|
}
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
/** Free a live game variable. */
|
|
|
|
void
|
|
|
|
free_live_game(LiveGame *match)
|
|
|
|
{
|
2005-03-10 21:59:39 +01:00
|
|
|
gint i, j, k;
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
if(match->units == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for(i=0;i<match->units->len;i++)
|
|
|
|
free_g_string(&g_array_index(match->units, LiveGameUnit, i).event.commentary);
|
2005-03-10 21:59:39 +01:00
|
|
|
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
{
|
|
|
|
for(j=0;j<LIVE_GAME_STAT_ARRAY_END;j++)
|
|
|
|
{
|
2005-03-11 13:17:48 +01:00
|
|
|
for(k=0;k<match->stats.players[i][j]->len;k++)
|
|
|
|
free_g_string((GString**)&g_ptr_array_index(match->stats.players[i][j], k));
|
2005-03-10 21:59:39 +01:00
|
|
|
|
2005-03-11 13:17:48 +01:00
|
|
|
free_g_ptr_array(&match->stats.players[i][j]);
|
2005-03-10 21:59:39 +01:00
|
|
|
}
|
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
free_g_array(&match->units);
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2004-12-23 13:58:39 +01:00
|
|
|
/**
|
|
|
|
Free the main variable of the game, #country.
|
|
|
|
*/
|
|
|
|
void
|
2005-04-06 10:49:55 +02:00
|
|
|
free_country(gboolean reset)
|
2004-12-23 13:58:39 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GString **strings[3] =
|
2004-12-30 17:48:19 +01:00
|
|
|
{&country.name, &country.symbol, &country.sid};
|
2004-12-23 13:58:39 +01:00
|
|
|
|
|
|
|
for(i=0;i<3;i++)
|
2005-04-06 10:49:55 +02:00
|
|
|
{
|
2004-12-30 17:48:19 +01:00
|
|
|
free_g_string(strings[i]);
|
2005-04-06 10:49:55 +02:00
|
|
|
if(reset)
|
|
|
|
*strings[i] = g_string_new("");
|
|
|
|
}
|
2004-12-23 13:58:39 +01:00
|
|
|
|
2005-04-06 10:49:55 +02:00
|
|
|
free_leagues_array(&ligs, reset);
|
|
|
|
free_cups_array(&cps, reset);
|
2005-05-06 18:35:19 +02:00
|
|
|
free_g_ptr_array(&acps);
|
2005-05-16 09:09:53 +02:00
|
|
|
|
2005-05-06 18:35:19 +02:00
|
|
|
if(reset)
|
|
|
|
acps = g_ptr_array_new();
|
2004-12-30 17:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Free the memory occupied by a leagues array.
|
|
|
|
@param leagues The pointer to the array we free.
|
|
|
|
*/
|
|
|
|
void
|
2005-04-04 12:36:04 +02:00
|
|
|
free_leagues_array(GArray **leagues, gboolean reset)
|
2004-12-30 17:48:19 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if(*leagues == NULL)
|
2005-04-04 12:36:04 +02:00
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
*leagues = g_array_new(FALSE, FALSE, sizeof(League));
|
2004-12-30 17:48:19 +01:00
|
|
|
return;
|
2005-04-04 12:36:04 +02:00
|
|
|
}
|
2004-12-30 17:48:19 +01:00
|
|
|
|
|
|
|
for(i=0;i<(*leagues)->len;i++)
|
|
|
|
free_league(&g_array_index(*leagues, League, i));
|
|
|
|
|
|
|
|
free_g_array(leagues);
|
2005-04-04 12:36:04 +02:00
|
|
|
|
|
|
|
if(reset)
|
|
|
|
*leagues = g_array_new(FALSE, FALSE, sizeof(League));
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Free the memory occupied by a league.
|
|
|
|
@param league The pointer to the league we free.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
free_league(League *league)
|
|
|
|
{
|
|
|
|
gint i;
|
2005-05-06 18:35:19 +02:00
|
|
|
GString **strings[6] =
|
2004-12-23 13:58:39 +01:00
|
|
|
{&league->name,
|
|
|
|
&league->short_name,
|
|
|
|
&league->symbol,
|
2004-12-30 17:48:19 +01:00
|
|
|
&league->sid,
|
2005-05-06 18:35:19 +02:00
|
|
|
&league->prom_rel.prom_games_dest_sid,
|
|
|
|
&league->prom_rel.prom_games_cup_sid};
|
2005-04-13 15:01:59 +02:00
|
|
|
GArray **arrays[2] =
|
2004-12-23 13:58:39 +01:00
|
|
|
{&league->teams,
|
2005-04-13 15:01:59 +02:00
|
|
|
&league->prom_rel.elements};
|
2004-12-23 13:58:39 +01:00
|
|
|
|
2005-05-06 18:35:19 +02:00
|
|
|
for(i=0;i<6;i++)
|
2004-12-30 17:48:19 +01:00
|
|
|
free_g_string(strings[i]);
|
2004-12-23 13:58:39 +01:00
|
|
|
|
|
|
|
if(league->teams != NULL)
|
2005-04-10 18:34:27 +02:00
|
|
|
free_teams_array(&league->teams, FALSE);
|
2004-12-23 13:58:39 +01:00
|
|
|
|
2005-04-13 15:01:59 +02:00
|
|
|
for(i=0;i<2;i++)
|
2004-12-30 17:48:19 +01:00
|
|
|
free_g_array(arrays[i]);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-04-13 15:01:59 +02:00
|
|
|
free_table(&league->table);
|
|
|
|
|
|
|
|
free_g_array(&league->fixtures);
|
2005-04-14 21:07:25 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
free_league_stats(&league->stats);
|
2005-04-13 15:01:59 +02:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
/** Free the league stats. */
|
|
|
|
void
|
|
|
|
free_league_stats(LeagueStat *stats)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for(i=0;i<stats->teams_off->len;i++)
|
|
|
|
g_string_free(g_array_index(stats->teams_off, Stat, i).value_string, TRUE);
|
|
|
|
free_g_array(&stats->teams_off);
|
|
|
|
|
|
|
|
for(i=0;i<stats->teams_def->len;i++)
|
|
|
|
g_string_free(g_array_index(stats->teams_def, Stat, i).value_string, TRUE);
|
|
|
|
free_g_array(&stats->teams_def);
|
|
|
|
|
|
|
|
for(i=0;i<stats->player_scorers->len;i++)
|
|
|
|
g_string_free(g_array_index(stats->player_scorers, Stat, i).value_string, TRUE);
|
|
|
|
free_g_array(&stats->player_scorers);
|
|
|
|
|
|
|
|
for(i=0;i<stats->player_goalies->len;i++)
|
|
|
|
g_string_free(g_array_index(stats->player_goalies, Stat, i).value_string, TRUE);
|
|
|
|
free_g_array(&stats->player_goalies);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-13 15:01:59 +02:00
|
|
|
/** Free a table. */
|
|
|
|
void
|
|
|
|
free_table(Table *table)
|
|
|
|
{
|
|
|
|
free_g_string(&table->name);
|
|
|
|
|
|
|
|
free_g_array(&table->elements);
|
2004-12-30 17:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Free the memory occupied by a teams array.
|
|
|
|
@param teams The pointer to the array we free. */
|
|
|
|
void
|
2005-04-10 18:34:27 +02:00
|
|
|
free_teams_array(GArray **teams, gboolean reset)
|
2004-12-30 17:48:19 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if(*teams == NULL)
|
2005-04-10 18:34:27 +02:00
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
*teams = g_array_new(FALSE, FALSE, sizeof(Team));
|
2004-12-30 17:48:19 +01:00
|
|
|
return;
|
2005-04-10 18:34:27 +02:00
|
|
|
}
|
2004-12-30 17:48:19 +01:00
|
|
|
|
|
|
|
for(i=0;i<(*teams)->len;i++)
|
|
|
|
free_team(&g_array_index(*teams, Team, i));
|
|
|
|
|
|
|
|
free_g_array(teams);
|
2005-04-10 18:34:27 +02:00
|
|
|
|
|
|
|
if(reset)
|
|
|
|
*teams = g_array_new(FALSE, FALSE, sizeof(Team));
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Free the memory occupied by a team.
|
2004-12-30 17:48:19 +01:00
|
|
|
@param tm The pointer to the team we free.
|
2004-12-23 13:58:39 +01:00
|
|
|
*/
|
|
|
|
void
|
2004-12-30 17:48:19 +01:00
|
|
|
free_team(Team *tm)
|
2004-12-23 13:58:39 +01:00
|
|
|
{
|
2005-06-21 15:33:16 +02:00
|
|
|
free_g_string(&tm->stadium.name);
|
2004-12-30 17:48:19 +01:00
|
|
|
free_g_string(&tm->name);
|
2005-06-21 15:33:16 +02:00
|
|
|
free_g_string(&tm->names_file);
|
2005-05-07 18:17:48 +02:00
|
|
|
free_g_string(&tm->symbol);
|
2005-06-21 15:33:16 +02:00
|
|
|
free_g_string(&tm->def_file);
|
2004-12-30 17:48:19 +01:00
|
|
|
|
2005-07-08 11:26:00 +02:00
|
|
|
free_player_array(&tm->players);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free an array containing players. */
|
|
|
|
void
|
|
|
|
free_player_array(GArray **players)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if(*players != NULL)
|
2004-12-23 13:58:39 +01:00
|
|
|
{
|
2005-07-08 11:26:00 +02:00
|
|
|
for(i=0;i<(*players)->len;i++)
|
|
|
|
free_player(&g_array_index((*players), Player, i));
|
2004-12-30 17:48:19 +01:00
|
|
|
|
2005-07-08 11:26:00 +02:00
|
|
|
free_g_array(players);
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
}
|
2004-12-30 17:48:19 +01:00
|
|
|
|
|
|
|
/** Free the memory occupied by a player.
|
|
|
|
@param pl The pointer to the player we free. */
|
|
|
|
void
|
|
|
|
free_player(Player *pl)
|
|
|
|
{
|
|
|
|
free_g_string(&pl->name);
|
|
|
|
|
|
|
|
free_g_array(&pl->cards);
|
2005-06-21 15:33:16 +02:00
|
|
|
free_g_array(&pl->games_goals);
|
2004-12-30 17:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Free the memory occupied by a cups array.
|
|
|
|
@param cups The pointer to the array we free.
|
|
|
|
*/
|
|
|
|
void
|
2005-04-04 12:36:04 +02:00
|
|
|
free_cups_array(GArray **cups, gboolean reset)
|
2004-12-30 17:48:19 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if(*cups == NULL)
|
2005-04-04 12:36:04 +02:00
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
*cups = g_array_new(FALSE, FALSE, sizeof(Cup));
|
2004-12-30 17:48:19 +01:00
|
|
|
return;
|
2005-04-04 12:36:04 +02:00
|
|
|
}
|
2004-12-30 17:48:19 +01:00
|
|
|
|
|
|
|
for(i=0;i<(*cups)->len;i++)
|
2005-05-06 18:35:19 +02:00
|
|
|
free_cup(&g_array_index(*cups, Cup, i));
|
2004-12-30 17:48:19 +01:00
|
|
|
|
|
|
|
free_g_array(cups);
|
2005-04-04 12:36:04 +02:00
|
|
|
|
|
|
|
if(reset)
|
|
|
|
*cups = g_array_new(FALSE, FALSE, sizeof(Cup));
|
2004-12-30 17:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Free the memory occupied by a cup.
|
|
|
|
@param cup The pointer to the cup we free.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
free_cup(Cup *cup)
|
|
|
|
{
|
2005-04-22 17:17:39 +02:00
|
|
|
gint i, j;
|
2004-12-30 17:48:19 +01:00
|
|
|
GString **strings[4] =
|
|
|
|
{&cup->name,
|
|
|
|
&cup->short_name,
|
|
|
|
&cup->symbol,
|
|
|
|
&cup->sid};
|
|
|
|
|
|
|
|
for(i=0;i<4;i++)
|
|
|
|
free_g_string(strings[i]);
|
|
|
|
|
2005-04-22 17:17:39 +02:00
|
|
|
for(i=0;i<cup->rounds->len;i++)
|
|
|
|
if(g_array_index(cup->rounds, CupRound, i).round_robin_number_of_groups > 0)
|
2005-05-08 19:56:26 +02:00
|
|
|
{
|
2005-04-22 17:17:39 +02:00
|
|
|
for(j=0;j<g_array_index(cup->rounds, CupRound, i).tables->len;j++)
|
|
|
|
free_table(&g_array_index(g_array_index(cup->rounds, CupRound, i).tables, Table, j));
|
|
|
|
|
2005-05-08 19:56:26 +02:00
|
|
|
for(j=0;j<g_array_index(cup->rounds, CupRound, i).choose_teams->len;j++)
|
|
|
|
free_cup_choose_team(
|
|
|
|
&g_array_index(g_array_index(cup->rounds, CupRound, i).choose_teams, CupChooseTeam, j));
|
|
|
|
|
|
|
|
free_g_array(&g_array_index(cup->rounds, CupRound, i).choose_teams);
|
|
|
|
free_teams_array(&g_array_index(cup->rounds, CupRound, i).teams, FALSE);
|
2005-08-15 18:25:49 +02:00
|
|
|
g_ptr_array_free(g_array_index(cup->rounds, CupRound, i).team_ptrs, TRUE);
|
2005-05-08 19:56:26 +02:00
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-05-08 19:56:26 +02:00
|
|
|
free_g_array(&cup->rounds);
|
2005-04-13 15:01:59 +02:00
|
|
|
free_g_array(&cup->fixtures);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
free_g_ptr_array(&cup->bye);
|
2005-05-06 18:35:19 +02:00
|
|
|
free_g_ptr_array(&cup->team_names);
|
2005-05-08 19:56:26 +02:00
|
|
|
free_g_ptr_array(&cup->teams);
|
2005-05-06 18:35:19 +02:00
|
|
|
free_g_string_array(&cup->properties);
|
2004-12-30 17:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Free the memory occupied by a CupChooseTeam.
|
|
|
|
@param cup_choose_team The pointer to the team we free.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
free_cup_choose_team(CupChooseTeam *cup_choose_team)
|
|
|
|
{
|
|
|
|
free_g_string(&cup_choose_team->sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free some global variables (except for the country variable). */
|
|
|
|
void
|
|
|
|
free_variables(void)
|
|
|
|
{
|
2005-03-24 08:42:24 +01:00
|
|
|
free_option_list(&options, FALSE);
|
2005-06-26 13:42:01 +02:00
|
|
|
free_option_list(&settings, FALSE);
|
2005-03-24 08:42:24 +01:00
|
|
|
free_option_list(&constants, FALSE);
|
2005-05-06 18:35:19 +02:00
|
|
|
free_option_list(&constants_app, FALSE);
|
2005-06-28 04:08:56 +02:00
|
|
|
free_option_list(&lg_tokens, FALSE);
|
2005-04-04 12:36:04 +02:00
|
|
|
|
|
|
|
free_g_string(&save_file);
|
2005-05-02 16:39:30 +02:00
|
|
|
|
2005-05-16 09:09:53 +02:00
|
|
|
g_rand_free(rand_generator);
|
|
|
|
|
2005-05-02 16:39:30 +02:00
|
|
|
free_season_stats(FALSE);
|
2004-12-30 17:48:19 +01:00
|
|
|
}
|
|
|
|
|
2005-07-01 22:51:46 +02:00
|
|
|
/** Free the list with live game commentary text. */
|
|
|
|
void
|
|
|
|
free_lg_commentary(gboolean reset)
|
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
|
|
|
|
for(i=0;i<LIVE_GAME_EVENT_END;i++)
|
|
|
|
if(lg_commentary[i] != NULL)
|
|
|
|
{
|
|
|
|
for(j=0;j<lg_commentary[i]->len;j++)
|
|
|
|
{
|
|
|
|
free_g_string(&g_array_index(lg_commentary[i], LGCommentary, j).text);
|
|
|
|
free_g_string(&g_array_index(lg_commentary[i], LGCommentary, j).condition);
|
|
|
|
}
|
|
|
|
|
|
|
|
free_g_array(&lg_commentary[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(reset)
|
|
|
|
for(i=0;i<LIVE_GAME_EVENT_END;i++)
|
|
|
|
lg_commentary[i] = g_array_new(FALSE, FALSE, sizeof(LGCommentary));
|
|
|
|
}
|
|
|
|
|
2004-12-30 17:48:19 +01:00
|
|
|
/**
|
|
|
|
Free a GPtrArray containing GStrings.
|
|
|
|
@param array The array to be freed.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
free_g_string_array(GPtrArray **array)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if(*array == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for(i=0;i<(*array)->len;i++)
|
|
|
|
free_g_string((GString**)&g_ptr_array_index(*array, i));
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
free_g_ptr_array(array);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free a GString if it isn't NULL.
|
|
|
|
@param string The string to be freed. */
|
|
|
|
void
|
|
|
|
free_g_string(GString **string)
|
|
|
|
{
|
|
|
|
if(*string == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_string_free(*string, TRUE);
|
|
|
|
|
|
|
|
*string = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free a GArray if it isn't NULL.
|
|
|
|
@param array The array to be freed. */
|
|
|
|
void
|
|
|
|
free_g_array(GArray **array)
|
|
|
|
{
|
|
|
|
if(*array == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_array_free(*array, TRUE);
|
|
|
|
|
|
|
|
*array = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free a GPtrArray if it isn't NULL.
|
|
|
|
@param array The array to be freed. */
|
|
|
|
void
|
|
|
|
free_g_ptr_array(GPtrArray **array)
|
|
|
|
{
|
|
|
|
if(*array == NULL)
|
|
|
|
return;
|
|
|
|
|
2004-12-30 17:48:19 +01:00
|
|
|
g_ptr_array_free(*array, TRUE);
|
|
|
|
|
|
|
|
*array = NULL;
|
|
|
|
}
|
2005-04-04 12:36:04 +02:00
|
|
|
|
|
|
|
/** Free the glist containing the support directories. */
|
|
|
|
void
|
|
|
|
free_support_dirs(void)
|
|
|
|
{
|
|
|
|
GList *elem = support_directories;
|
|
|
|
|
|
|
|
if(elem == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while(elem)
|
|
|
|
{
|
|
|
|
g_free ((gchar*)elem->data);
|
|
|
|
elem = elem->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(support_directories);
|
|
|
|
support_directories = NULL;
|
|
|
|
}
|
2005-06-01 20:19:02 +02:00
|
|
|
|
|
|
|
/** Free a list of names. */
|
|
|
|
void
|
|
|
|
free_name_list(NameList *namelist, gboolean reset)
|
|
|
|
{
|
|
|
|
if(namelist->sid == NULL)
|
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
{
|
|
|
|
namelist->sid = g_string_new("");
|
|
|
|
namelist->first_names = g_ptr_array_new();
|
|
|
|
namelist->last_names = g_ptr_array_new();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
free_g_string(&namelist->sid);
|
|
|
|
free_g_ptr_array(&namelist->first_names);
|
|
|
|
free_g_ptr_array(&namelist->last_names);
|
|
|
|
|
|
|
|
if(reset)
|
|
|
|
{
|
|
|
|
namelist->sid = g_string_new("");
|
|
|
|
namelist->first_names = g_ptr_array_new();
|
|
|
|
namelist->last_names = g_ptr_array_new();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Free the array with the name lists. */
|
|
|
|
void
|
|
|
|
free_names(gboolean reset)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if(name_lists == NULL)
|
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<name_lists->len;i++)
|
|
|
|
free_name_list(&g_array_index(name_lists, NameList, i), FALSE);
|
|
|
|
|
|
|
|
free_g_array(&name_lists);
|
|
|
|
|
|
|
|
if(reset)
|
|
|
|
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
|
|
|
|
}
|