Author: cazfi Date: Sat Apr 11 23:02:42 2015 New Revision: 28757 URL: http://svn.gna.org/viewcvs/freeciv?rev=28757&view=rev Log: Free multicast group name on exit.
See patch #5989 Modified: trunk/common/fc_interface.c trunk/utility/shared.c trunk/utility/shared.h Modified: trunk/common/fc_interface.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_interface.c?rev=28757&r1=28756&r2=28757&view=diff ============================================================================== --- trunk/common/fc_interface.c (original) +++ trunk/common/fc_interface.c Sat Apr 11 23:02:42 2015 @@ -70,4 +70,5 @@ void free_libfreeciv(void) { free_data_dir_names(); + free_multicast_group(); } Modified: trunk/utility/shared.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/utility/shared.c?rev=28757&r1=28756&r2=28757&view=diff ============================================================================== --- trunk/utility/shared.c (original) +++ trunk/utility/shared.c Sat Apr 11 23:02:42 2015 @@ -115,6 +115,8 @@ static struct strvec *data_dir_names = NULL; static struct strvec *save_dir_names = NULL; static struct strvec *scenario_dir_names = NULL; + +static char *mc_group = NULL; static int compare_file_mtime_ptrs(const struct fileinfo *const *ppa, const struct fileinfo *const *ppb); @@ -1681,31 +1683,41 @@ ***************************************************************************/ char *get_multicast_group(bool ipv6_prefered) { - static bool init = FALSE; - static char *group = NULL; static char *default_multicast_group_ipv4 = "225.1.1.1"; #ifdef IPV6_SUPPORT /* TODO: Get useful group (this is node local) */ static char *default_multicast_group_ipv6 = "FF31::8000:15B4"; -#endif - - if (!init) { +#endif /* IPv6 support */ + + if (mc_group == NULL) { char *env = getenv("FREECIV_MULTICAST_GROUP"); + if (env) { - group = fc_strdup(env); + mc_group = fc_strdup(env); } else { #ifdef IPV6_SUPPORT if (ipv6_prefered) { - group = fc_strdup(default_multicast_group_ipv6); + mc_group = fc_strdup(default_multicast_group_ipv6); } else #endif /* IPv6 support */ { - group = fc_strdup(default_multicast_group_ipv4); - } - } - init = TRUE; - } - return group; + mc_group = fc_strdup(default_multicast_group_ipv4); + } + } + } + + return mc_group; +} + +/*************************************************************************** + Free multicast group resources +***************************************************************************/ +void free_multicast_group(void) +{ + if (mc_group != NULL) { + free(mc_group); + mc_group = NULL; + } } /*************************************************************************** Modified: trunk/utility/shared.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/utility/shared.h?rev=28757&r1=28756&r2=28757&view=diff ============================================================================== --- trunk/utility/shared.h (original) +++ trunk/utility/shared.h Sat Apr 11 23:02:42 2015 @@ -209,6 +209,7 @@ int *pnum_matches); char *get_multicast_group(bool ipv6_prefered); +void free_multicast_group(void); void interpret_tilde(char* buf, size_t buf_size, const char* filename); char *interpret_tilde_alloc(const char* filename); char *skip_to_basename(char *filepath); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits