Author: cazfi
Date: Fri Apr 24 21:38:03 2015
New Revision: 28864

URL: http://svn.gna.org/viewcvs/freeciv?rev=28864&view=rev
Log:
Free memory allocated by map generator on exit.

See patch #6030

Modified:
    branches/S2_6/server/generator/utilities.c
    branches/S2_6/server/generator/utilities.h
    branches/S2_6/server/srv_main.c

Modified: branches/S2_6/server/generator/utilities.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/generator/utilities.c?rev=28864&r1=28863&r2=28864&view=diff
==============================================================================
--- branches/S2_6/server/generator/utilities.c  (original)
+++ branches/S2_6/server/generator/utilities.c  Fri Apr 24 21:38:03 2015
@@ -239,9 +239,9 @@
  * The _sizes arrays give the sizes (in tiles) of each continent and
  * ocean.
  */
-static Continent_id *lake_surrounders;
-static int *continent_sizes, *ocean_sizes;
-
+static Continent_id *lake_surrounders = NULL;
+static int *continent_sizes = NULL;
+static int *ocean_sizes = NULL;
 
 /**************************************************************************
   Calculate lake_surrounders[] array
@@ -252,7 +252,7 @@
 
   lake_surrounders = fc_realloc(lake_surrounders, size);
   memset(lake_surrounders, 0, size);
-  
+
   whole_map_iterate(ptile) {
     const struct terrain *pterrain = tile_terrain(ptile);
     Continent_id cont = tile_continent(ptile);
@@ -602,3 +602,22 @@
     }
   } whole_map_iterate_end;
 }
+
+/**************************************************************************
+  Free resources allocated by the generator.
+**************************************************************************/
+void generator_free(void)
+{
+  if (lake_surrounders != NULL) {
+    free(lake_surrounders);
+    lake_surrounders = NULL;
+  }
+  if (continent_sizes != NULL) {
+    free(continent_sizes);
+    continent_sizes = NULL;
+  }
+  if (ocean_sizes != NULL) {
+    free(ocean_sizes);
+    ocean_sizes = NULL;
+  }
+}

Modified: branches/S2_6/server/generator/utilities.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/generator/utilities.h?rev=28864&r1=28863&r2=28864&view=diff
==============================================================================
--- branches/S2_6/server/generator/utilities.h  (original)
+++ branches/S2_6/server/generator/utilities.h  Fri Apr 24 21:38:03 2015
@@ -14,6 +14,8 @@
 #define FC__UTILITIES_H
 
 typedef void (*tile_knowledge_cb)(struct tile *ptile);
+
+void generator_free(void);
 
 void regenerate_lakes(tile_knowledge_cb knowledge_cb);
 void smooth_water_depth(void);

Modified: branches/S2_6/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/srv_main.c?rev=28864&r1=28863&r2=28864&view=diff
==============================================================================
--- branches/S2_6/server/srv_main.c     (original)
+++ branches/S2_6/server/srv_main.c     Fri Apr 24 21:38:03 2015
@@ -85,6 +85,7 @@
 
 /* server/generator */
 #include "mapgen.h"
+#include "utilities.h"
 
 /* server/scripting */
 #include "script_server.h"
@@ -1549,6 +1550,7 @@
   stdinhand_free();
   edithand_free();
   voting_free();
+  generator_free();
   close_connections_and_socket();
   rulesets_deinit();
   timing_log_free();


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

Reply via email to