mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
Free some extra memory when exiting WeeChat
This commit is contained in:
+17
-7
@@ -67,20 +67,29 @@ const int gnutls_cert_type_prio[] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
|
||||
/*
|
||||
* network_init: init network
|
||||
*/
|
||||
|
||||
void
|
||||
network_init ()
|
||||
{
|
||||
#ifdef HAVE_GNUTLS
|
||||
char *CApath, *CApath2;
|
||||
char *ca_path, *ca_path2;
|
||||
|
||||
gnutls_global_init ();
|
||||
gnutls_certificate_allocate_credentials (&gnutls_xcred);
|
||||
|
||||
CApath = string_replace (CONFIG_STRING(config_network_gnutls_ca_file),
|
||||
"~", getenv ("HOME"));
|
||||
CApath2 = string_replace (CApath, "%h", weechat_home);
|
||||
|
||||
gnutls_certificate_set_x509_trust_file (gnutls_xcred, CApath2, GNUTLS_X509_FMT_PEM);
|
||||
|
||||
ca_path = string_replace (CONFIG_STRING(config_network_gnutls_ca_file),
|
||||
"~", getenv ("HOME"));
|
||||
if (ca_path)
|
||||
{
|
||||
ca_path2 = string_replace (ca_path, "%h", weechat_home);
|
||||
if (ca_path2)
|
||||
{
|
||||
gnutls_certificate_set_x509_trust_file (gnutls_xcred, ca_path2,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
free (ca_path2);
|
||||
}
|
||||
free (ca_path);
|
||||
}
|
||||
gnutls_certificate_client_set_retrieve_function (gnutls_xcred,
|
||||
&hook_connect_gnutls_set_certificates);
|
||||
network_init_ok = 1;
|
||||
@@ -102,6 +111,7 @@ network_end ()
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (network_init_ok)
|
||||
{
|
||||
network_init_ok = 0;
|
||||
gnutls_certificate_free_credentials (gnutls_xcred);
|
||||
gnutls_global_deinit();
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ gui_main_pre_init (int *argc, char **argv[])
|
||||
/* pre-init colors */
|
||||
gui_color_pre_init ();
|
||||
|
||||
/* build empty prefixes (before reading config) */
|
||||
gui_chat_prefix_build_empty ();
|
||||
/* init some variables for chat area */
|
||||
gui_chat_init ();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -401,8 +401,8 @@ gui_main_end (int clean_exit)
|
||||
/* end color */
|
||||
gui_color_end ();
|
||||
|
||||
/* free chat buffer */
|
||||
gui_chat_free_buffer ();
|
||||
/* free some variables used for chat area */
|
||||
gui_chat_end ();
|
||||
}
|
||||
|
||||
/* end of Curses output */
|
||||
|
||||
@@ -70,8 +70,8 @@ gui_main_pre_init (int *argc, char **argv[])
|
||||
/* pre-init colors */
|
||||
gui_color_pre_init ();
|
||||
|
||||
/* build empty prefixes (before reading config) */
|
||||
gui_chat_prefix_build_empty ();
|
||||
/* init some variables for chat area */
|
||||
gui_chat_init ();
|
||||
|
||||
/* Initialise Gtk */
|
||||
gtk_init (argc, argv);
|
||||
@@ -277,7 +277,7 @@ gui_main_end (int clean_exit)
|
||||
/* end color */
|
||||
gui_color_end ();
|
||||
|
||||
/* free chat buffer */
|
||||
gui_chat_free_buffer ();
|
||||
/* free some variables used for chat area */
|
||||
gui_chat_end ();
|
||||
}
|
||||
}
|
||||
|
||||
+19
-5
@@ -55,13 +55,14 @@ struct t_gui_buffer *gui_chat_mute_buffer = NULL; /* mute buffer */
|
||||
|
||||
|
||||
/*
|
||||
* gui_chat_prefix_build_empty: build empty prefixes
|
||||
* (called before reading WeeChat config file)
|
||||
* gui_chat_init: init some variables for chat area
|
||||
* (called before reading WeeChat config file)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_prefix_build_empty ()
|
||||
gui_chat_init ()
|
||||
{
|
||||
/* build empty prefixes */
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (gui_chat_prefix_empty);
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (gui_chat_prefix_empty);
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (gui_chat_prefix_empty);
|
||||
@@ -651,15 +652,28 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_free_buffer: free buffer used by chat functions
|
||||
* gui_chat_end: free some variables allocated for chat area
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_free_buffer ()
|
||||
gui_chat_end ()
|
||||
{
|
||||
int i;
|
||||
|
||||
/* free buffer used by chat functions */
|
||||
if (gui_chat_buffer)
|
||||
{
|
||||
free (gui_chat_buffer);
|
||||
gui_chat_buffer = NULL;
|
||||
}
|
||||
|
||||
/* free prefixes */
|
||||
for (i = 0; i < GUI_CHAT_NUM_PREFIXES; i++)
|
||||
{
|
||||
if (gui_chat_prefix[i])
|
||||
{
|
||||
free (gui_chat_prefix[i]);
|
||||
gui_chat_prefix[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ extern struct t_gui_buffer *gui_chat_mute_buffer;
|
||||
|
||||
/* chat functions */
|
||||
|
||||
extern void gui_chat_prefix_build_empty ();
|
||||
extern void gui_chat_init ();
|
||||
extern void gui_chat_prefix_build ();
|
||||
extern int gui_chat_strlen_screen (const char *string);
|
||||
extern char *gui_chat_string_add_offset (const char *string, int offset);
|
||||
@@ -75,7 +75,7 @@ extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
|
||||
const char *message, ...);
|
||||
extern void gui_chat_printf_y (struct t_gui_buffer *buffer, int y,
|
||||
const char *message, ...);
|
||||
extern void gui_chat_free_buffer ();
|
||||
extern void gui_chat_end ();
|
||||
|
||||
/* chat functions (GUI dependent) */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user