Author: cazfi
Date: Fri Mar 27 01:06:00 2015
New Revision: 28628

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

See patch #5946

Modified:
    branches/S2_5/server/advisors/autosettlers.c
    branches/S2_5/server/advisors/autosettlers.h
    branches/S2_5/server/srv_main.c

Modified: branches/S2_5/server/advisors/autosettlers.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/advisors/autosettlers.c?rev=28628&r1=28627&r2=28628&view=diff
==============================================================================
--- branches/S2_5/server/advisors/autosettlers.c        (original)
+++ branches/S2_5/server/advisors/autosettlers.c        Fri Mar 27 01:06:00 2015
@@ -67,6 +67,17 @@
   int enroute; /* unit ID of settler en route to this tile */
   int eta; /* estimated number of turns until enroute arrives */
 };
+
+static struct timer *as_timer = NULL;
+
+/**************************************************************************
+  Free resources allocated for autosettlers system
+**************************************************************************/
+void adv_settlers_free(void)
+{
+  timer_destroy(as_timer);
+  as_timer = NULL;
+}
 
 /**************************************************************************
   Calculate the attractiveness of building a road/rail at the given tile.
@@ -880,13 +891,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. */
@@ -959,12 +969,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: branches/S2_5/server/advisors/autosettlers.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/advisors/autosettlers.h?rev=28628&r1=28627&r2=28628&view=diff
==============================================================================
--- branches/S2_5/server/advisors/autosettlers.h        (original)
+++ branches/S2_5/server/advisors/autosettlers.h        Fri Mar 27 01:06:00 2015
@@ -19,6 +19,8 @@
 
 struct settlermap;
 struct pf_path;
+
+void adv_settlers_free(void);
 
 void auto_settlers_player(struct player *pplayer);
 

Modified: branches/S2_5/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_main.c?rev=28628&r1=28627&r2=28628&view=diff
==============================================================================
--- branches/S2_5/server/srv_main.c     (original)
+++ branches/S2_5/server/srv_main.c     Fri Mar 27 01:06:00 2015
@@ -1404,6 +1404,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