Author: cazfi Date: Wed May 17 05:29:16 2017 New Revision: 35618 URL: http://svn.gna.org/viewcvs/freeciv?rev=35618&view=rev Log: Free ai_type private data
See hrm Bug #660840 Modified: branches/S3_0/ai/classic/classicai.c branches/S3_0/ai/tex/texai.c branches/S3_0/ai/threaded/threadedai.c branches/S3_0/common/ai.h branches/S3_0/doc/README.AI_modules branches/S3_0/server/srv_main.c Modified: branches/S3_0/ai/classic/classicai.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/ai/classic/classicai.c?rev=35618&r1=35617&r2=35618&view=diff ============================================================================== --- branches/S3_0/ai/classic/classicai.c (original) +++ branches/S3_0/ai/classic/classicai.c Wed May 17 05:29:16 2017 @@ -70,6 +70,16 @@ } /************************************************************************** + Free resources allocated by the classic AI module +**************************************************************************/ +static void cai_module_close(void) +{ + struct ai_type *deftype = classic_ai_get_self(); + + FC_FREE(deftype->private); +} + +/************************************************************************** Call default ai with classic ai type as parameter. **************************************************************************/ static void cai_player_alloc(struct player *pplayer) @@ -578,6 +588,8 @@ private = fc_malloc(sizeof(struct dai_private_data)); private->contemplace_workers = TRUE; ai->private = private; + + ai->funcs.module_close = cai_module_close; /* ai->funcs.game_start = NULL; */ /* ai->funcs.game_free = NULL; */ Modified: branches/S3_0/ai/tex/texai.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/ai/tex/texai.c?rev=35618&r1=35617&r2=35618&view=diff ============================================================================== --- branches/S3_0/ai/tex/texai.c (original) +++ branches/S3_0/ai/tex/texai.c Wed May 17 05:29:16 2017 @@ -67,6 +67,16 @@ #define TEXAI_DFUNC(_func, ...) _func(ait, ## __VA_ARGS__ ); /************************************************************************** + Free resources allocated by the tex AI module +**************************************************************************/ +static void texai_module_close(void) +{ + TEXAI_AIT; + + FC_FREE(ait->private); +} + +/************************************************************************** Call default ai with tex ai type as parameter. **************************************************************************/ static void texwai_player_alloc(struct player *pplayer) @@ -566,6 +576,7 @@ texai_init_self(ai); + ai->funcs.module_close = texai_module_close; ai->funcs.player_alloc = texwai_player_alloc; ai->funcs.player_free = texwai_player_free; ai->funcs.player_save = texwai_player_save; Modified: branches/S3_0/ai/threaded/threadedai.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/ai/threaded/threadedai.c?rev=35618&r1=35617&r2=35618&view=diff ============================================================================== --- branches/S3_0/ai/threaded/threadedai.c (original) +++ branches/S3_0/ai/threaded/threadedai.c Wed May 17 05:29:16 2017 @@ -66,6 +66,16 @@ #define TAI_DFUNC(_func, ...) _func(ait, ## __VA_ARGS__ ); /************************************************************************** + Free resources allocated by the threaded AI module +**************************************************************************/ +static void tai_module_close(void) +{ + TAI_AIT; + + FC_FREE(ait->private); +} + +/************************************************************************** Call default ai with threaded ai type as parameter. **************************************************************************/ static void twai_player_alloc(struct player *pplayer) @@ -552,6 +562,7 @@ tai_init_self(ai); + ai->funcs.module_close = tai_module_close; ai->funcs.player_alloc = twai_player_alloc; ai->funcs.player_free = twai_player_free; ai->funcs.player_save = twai_player_save; Modified: branches/S3_0/common/ai.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/ai.h?rev=35618&r1=35617&r2=35618&view=diff ============================================================================== --- branches/S3_0/common/ai.h (original) +++ branches/S3_0/common/ai.h Wed May 17 05:29:16 2017 @@ -55,6 +55,9 @@ void *private; struct { + /* Called for every AI type when server quits. */ + void (*module_close)(void); + /* Called for every AI type when game starts. Game is not necessarily new one, it can also be an old game loaded from a savegame. */ void (*game_start)(void); Modified: branches/S3_0/doc/README.AI_modules URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/doc/README.AI_modules?rev=35618&r1=35617&r2=35618&view=diff ============================================================================== --- branches/S3_0/doc/README.AI_modules (original) +++ branches/S3_0/doc/README.AI_modules Wed May 17 05:29:16 2017 @@ -119,6 +119,7 @@ New in Freeciv 3.0: ------------------- - Added 'private' pointer for ai module to store data of its own +- Added 'module_close', called when server quits - Added 'player_console', called when user enter aicmd - Added 'city_created', 'city_destroyed', 'unit_created', and 'unit_destroyed' They are like 'city_alloc', 'city_free', 'unit_alloc', and 'unit_free' but called Modified: branches/S3_0/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/srv_main.c?rev=35618&r1=35617&r2=35618&view=diff ============================================================================== --- branches/S3_0/server/srv_main.c (original) +++ branches/S3_0/server/srv_main.c Wed May 17 05:29:16 2017 @@ -1618,6 +1618,7 @@ close_connections_and_socket(); rulesets_deinit(); ruleset_choices_free(); + CALL_FUNC_EACH_AI(module_close); timing_log_free(); registry_module_close(); fc_destroy_mutex(&game.server.mutexes.city_list); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits