Author: cazfi
Date: Fri Apr 15 15:30:34 2016
New Revision: 32409

URL: http://svn.gna.org/viewcvs/freeciv?rev=32409&view=rev
Log:
Free individual items from allowed_govs, allowed_styles, and allowed_terrains 
vectors.

See bug #24561

Modified:
    branches/S2_6/common/game.c
    branches/S2_6/common/game.h
    branches/S2_6/server/ruleset.c
    branches/S2_6/tools/ruledit/rulesave.c

Modified: branches/S2_6/common/game.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/game.c?rev=32409&r1=32408&r2=32409&view=diff
==============================================================================
--- branches/S2_6/common/game.c (original)
+++ branches/S2_6/common/game.c Fri Apr 15 15:30:34 2016
@@ -546,6 +546,9 @@
     game.server.ruledit.allowed_govs = NULL;
     game.server.ruledit.allowed_terrains = NULL;
     game.server.ruledit.allowed_styles = NULL;
+    game.server.ruledit.nc_agovs = NULL;
+    game.server.ruledit.nc_aterrs = NULL;
+    game.server.ruledit.nc_astyles = NULL;
     game.server.ruledit.ag_count = 0;
     game.server.ruledit.at_count = 0;
     game.server.ruledit.as_count = 0;
@@ -618,16 +621,28 @@
       game.server.ruledit.embedded_nations = NULL;
       game.server.ruledit.embedded_nations_count = 0;
       if (game.server.ruledit.allowed_govs != NULL) {
+        for (i = 0; i < game.server.ruledit.ag_count; i++) {
+          free(game.server.ruledit.nc_agovs[i]);
+        }
         free(game.server.ruledit.allowed_govs);
         game.server.ruledit.allowed_govs = NULL;
+        game.server.ruledit.nc_agovs = NULL;
       }
       if (game.server.ruledit.allowed_terrains != NULL) {
+        for (i = 0; i < game.server.ruledit.at_count; i++) {
+          free(game.server.ruledit.nc_aterrs[i]);
+        }
         free(game.server.ruledit.allowed_terrains);
         game.server.ruledit.allowed_terrains = NULL;
+        game.server.ruledit.nc_aterrs = NULL;
       }
       if (game.server.ruledit.allowed_styles != NULL) {
+        for (i = 0; i < game.server.ruledit.as_count; i++) {
+          free(game.server.ruledit.nc_astyles[i]);
+        }
         free(game.server.ruledit.allowed_styles);
         game.server.ruledit.allowed_styles = NULL;
+        game.server.ruledit.nc_astyles = NULL;
       }
     }
   }

Modified: branches/S2_6/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/game.h?rev=32409&r1=32408&r2=32409&view=diff
==============================================================================
--- branches/S2_6/common/game.h (original)
+++ branches/S2_6/common/game.h Fri Apr 15 15:30:34 2016
@@ -263,10 +263,13 @@
         char **embedded_nations;
         size_t embedded_nations_count;
         const char **allowed_govs;
+        char **nc_agovs;
         size_t ag_count;
         const char **allowed_terrains;
+        char **nc_aterrs;
         size_t at_count;
         const char **allowed_styles;
+        char **nc_astyles;
         size_t as_count;
       } ruledit;
     } server;

Modified: branches/S2_6/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/ruleset.c?rev=32409&r1=32408&r2=32409&view=diff
==============================================================================
--- branches/S2_6/server/ruleset.c      (original)
+++ branches/S2_6/server/ruleset.c      Fri Apr 15 15:30:34 2016
@@ -3946,8 +3946,10 @@
                                  "compatibility.allowed_govs");
     if (vec != NULL) {
       /* Copy to persistent vector */
-      game.server.ruledit.allowed_govs
+      game.server.ruledit.nc_agovs
         = fc_malloc(game.server.ruledit.ag_count * sizeof(char *));
+      game.server.ruledit.allowed_govs =
+        (const char **)game.server.ruledit.nc_agovs;
 
       for (j = 0; j < game.server.ruledit.ag_count; j++) {
         game.server.ruledit.allowed_govs[j] = fc_strdup(vec[j]);
@@ -3960,8 +3962,10 @@
                                  "compatibility.allowed_terrains");
     if (vec != NULL) {
       /* Copy to persistent vector */
-      game.server.ruledit.allowed_terrains
+      game.server.ruledit.nc_aterrs
         = fc_malloc(game.server.ruledit.at_count * sizeof(char *));
+      game.server.ruledit.allowed_terrains =
+        (const char **)game.server.ruledit.nc_aterrs;
 
       for (j = 0; j < game.server.ruledit.at_count; j++) {
         game.server.ruledit.allowed_terrains[j] = fc_strdup(vec[j]);
@@ -3974,8 +3978,10 @@
                                  "compatibility.allowed_styles");
     if (vec != NULL) {
       /* Copy to persistent vector */
-      game.server.ruledit.allowed_styles
+      game.server.ruledit.nc_astyles
         = fc_malloc(game.server.ruledit.as_count * sizeof(char *));
+      game.server.ruledit.allowed_styles =
+        (const char **)game.server.ruledit.nc_astyles;
 
       for (j = 0; j < game.server.ruledit.as_count; j++) {
         game.server.ruledit.allowed_styles[j] = fc_strdup(vec[j]);

Modified: branches/S2_6/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/rulesave.c?rev=32409&r1=32408&r2=32409&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/rulesave.c      (original)
+++ branches/S2_6/tools/ruledit/rulesave.c      Fri Apr 15 15:30:34 2016
@@ -1429,15 +1429,18 @@
               "default_traits", "");
 
   if (game.server.ruledit.allowed_govs != NULL) {
-    secfile_insert_str_vec(sfile, game.server.ruledit.allowed_govs, 
game.server.ruledit.ag_count,
+    secfile_insert_str_vec(sfile, game.server.ruledit.allowed_govs,
+                           game.server.ruledit.ag_count,
                            "compatibility.allowed_govs");
   }
   if (game.server.ruledit.allowed_terrains != NULL) {
-    secfile_insert_str_vec(sfile, game.server.ruledit.allowed_terrains, 
game.server.ruledit.at_count,
+    secfile_insert_str_vec(sfile, game.server.ruledit.allowed_terrains,
+                           game.server.ruledit.at_count,
                            "compatibility.allowed_terrains");
   }
   if (game.server.ruledit.allowed_styles != NULL) {
-    secfile_insert_str_vec(sfile, game.server.ruledit.allowed_styles, 
game.server.ruledit.as_count,
+    secfile_insert_str_vec(sfile, game.server.ruledit.allowed_styles,
+                           game.server.ruledit.as_count,
                            "compatibility.allowed_styles");
   }
 


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

Reply via email to