Author: cazfi
Date: Mon Jul 27 11:38:35 2015
New Revision: 29248

URL: http://svn.gna.org/viewcvs/freeciv?rev=29248&view=rev
Log:
Free homedir information on exit

See patch #6140

Modified:
    branches/S2_5/common/fc_interface.c
    branches/S2_5/utility/shared.c
    branches/S2_5/utility/shared.h

Modified: branches/S2_5/common/fc_interface.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/fc_interface.c?rev=29248&r1=29247&r2=29248&view=diff
==============================================================================
--- branches/S2_5/common/fc_interface.c (original)
+++ branches/S2_5/common/fc_interface.c Mon Jul 27 11:38:35 2015
@@ -71,4 +71,5 @@
 {
   free_data_dir_names();
   free_multicast_group();
+  free_user_home_dir();
 }

Modified: branches/S2_5/utility/shared.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/utility/shared.c?rev=29248&r1=29247&r2=29248&view=diff
==============================================================================
--- branches/S2_5/utility/shared.c      (original)
+++ branches/S2_5/utility/shared.c      Mon Jul 27 11:38:35 2015
@@ -117,6 +117,7 @@
 static struct strvec *scenario_dir_names = NULL;
 
 static char *mc_group = NULL;
+static char *home_dir = NULL;
 
 static int compare_file_mtime_ptrs(const struct fileinfo *const *ppa,
                                    const struct fileinfo *const *ppb);
@@ -743,12 +744,11 @@
   return "PROGDIR:";
 #else  /* AMIGA */
   static bool init = FALSE;
-  static char *home_dir = NULL;
 
   if (!init) {
     char *env = getenv("HOME");
     if (env) {
-      home_dir = fc_strdup(env);        /* never free()d */
+      home_dir = fc_strdup(env);
       log_verbose("HOME is %s", home_dir);
     } else {
 
@@ -804,6 +804,17 @@
 
   return home_dir;
 #endif /* AMIGA */
+}
+
+/***************************************************************************
+  Free user home directory information
+***************************************************************************/
+void free_user_home_dir(void)
+{
+  if (home_dir != NULL) {
+    free(home_dir);
+    home_dir = NULL;
+  }
 }
 
 /***************************************************************************

Modified: branches/S2_5/utility/shared.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/utility/shared.h?rev=29248&r1=29247&r2=29248&view=diff
==============================================================================
--- branches/S2_5/utility/shared.h      (original)
+++ branches/S2_5/utility/shared.h      Mon Jul 27 11:38:35 2015
@@ -155,8 +155,9 @@
 #define fileinfo_list_iterate_end LIST_ITERATE_END
 
 char *user_home_dir(void);
+void free_user_home_dir(void);
 char *user_username(char *buf, size_t bufsz);
-  
+
 const struct strvec *get_data_dirs(void);
 const struct strvec *get_save_dirs(void);
 const struct strvec *get_scenario_dirs(void);


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

Reply via email to