Author: cazfi
Date: Mon Jul 27 11:38:25 2015
New Revision: 29247

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

See patch #6140

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

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

Modified: branches/S2_6/utility/shared.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/shared.c?rev=29247&r1=29246&r2=29247&view=diff
==============================================================================
--- branches/S2_6/utility/shared.c      (original)
+++ branches/S2_6/utility/shared.c      Mon Jul 27 11:38:25 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_6/utility/shared.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/shared.h?rev=29247&r1=29246&r2=29247&view=diff
==============================================================================
--- branches/S2_6/utility/shared.h      (original)
+++ branches/S2_6/utility/shared.h      Mon Jul 27 11:38:25 2015
@@ -149,8 +149,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