Author: cazfi
Date: Fri Mar 27 01:05:45 2015
New Revision: 28626

URL: http://svn.gna.org/viewcvs/freeciv?rev=28626&view=rev
Log:
Free autosettlers timer

See patch #5946

Modified:
    trunk/server/advisors/autosettlers.c
    trunk/server/advisors/autosettlers.h
    trunk/server/srv_main.c

Modified: trunk/server/advisors/autosettlers.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/autosettlers.c?rev=28626&r1=28625&r2=28626&view=diff
==============================================================================
--- trunk/server/advisors/autosettlers.c        (original)
+++ trunk/server/advisors/autosettlers.c        Fri Mar 27 01:05:45 2015
@@ -76,6 +76,17 @@
 Activity_type_id as_activities_transform[ACTIVITY_LAST];
 Activity_type_id as_activities_extra[ACTIVITY_LAST];
 Activity_type_id as_activities_rmextra[ACTIVITY_LAST];
+
+static struct timer *as_timer = NULL;
+
+/**************************************************************************
+  Free resources allocated for autosettlers system
+**************************************************************************/
+void adv_settlers_free(void)
+{
+  timer_destroy(as_timer);
+  as_timer = NULL;
+}
 
 /**************************************************************************
   Initialize advisor systems.
@@ -1044,13 +1055,12 @@
 **************************************************************************/
 void auto_settlers_player(struct player *pplayer) 
 {
-  static struct timer *t = NULL;      /* alloc once, never free */
   struct settlermap *state;
 
   state = fc_calloc(MAP_INDEX_SIZE, sizeof(*state));
 
-  t = timer_renew(t, TIMER_CPU, TIMER_DEBUG);
-  timer_start(t);
+  as_timer = timer_renew(as_timer, TIMER_CPU, TIMER_DEBUG);
+  timer_start(as_timer);
 
   if (pplayer->ai_controlled) {
     /* Set up our city map. */
@@ -1123,12 +1133,12 @@
     CALL_PLR_AI_FUNC(settler_reset, pplayer, pplayer);
   }
 
-  if (timer_in_use(t)) {
+  if (timer_in_use(as_timer)) {
 
 #ifdef LOG_TIMERS
     log_verbose("%s autosettlers consumed %g milliseconds.",
                 nation_rule_name(nation_of_player(pplayer)),
-                1000.0 * timer_read_seconds(t));
+                1000.0 * timer_read_seconds(as_timer));
 #else
     log_verbose("%s autosettlers finished",
                 nation_rule_name(nation_of_player(pplayer)));

Modified: trunk/server/advisors/autosettlers.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/autosettlers.h?rev=28626&r1=28625&r2=28626&view=diff
==============================================================================
--- trunk/server/advisors/autosettlers.h        (original)
+++ trunk/server/advisors/autosettlers.h        Fri Mar 27 01:05:45 2015
@@ -21,6 +21,8 @@
 
 struct settlermap;
 struct pf_path;
+
+void adv_settlers_free(void);
 
 void auto_settlers_player(struct player *pplayer);
 

Modified: trunk/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=28626&r1=28625&r2=28626&view=diff
==============================================================================
--- trunk/server/srv_main.c     (original)
+++ trunk/server/srv_main.c     Fri Mar 27 01:05:45 2015
@@ -1565,6 +1565,7 @@
   server_game_free();
   diplhand_free();
   voting_free();
+  adv_settlers_free();
   ai_timer_free();
 
 #ifdef HAVE_FCDB


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to