summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--src/common/command.c24
-rw-r--r--src/common/command.h2
-rw-r--r--src/common/history.c47
-rw-r--r--src/common/history.h2
-rw-r--r--src/common/weechat.c44
-rw-r--r--src/common/weechat.h2
-rw-r--r--src/gui/curses/gui-display.c13
-rw-r--r--src/gui/curses/gui-input.c4
-rw-r--r--src/gui/gui-common.c23
-rw-r--r--src/gui/gui.h1
-rw-r--r--src/irc/irc-server.c3
-rw-r--r--src/plugins/plugins.c1
-rw-r--r--weechat/ChangeLog13
-rw-r--r--weechat/src/common/command.c24
-rw-r--r--weechat/src/common/command.h2
-rw-r--r--weechat/src/common/history.c47
-rw-r--r--weechat/src/common/history.h2
-rw-r--r--weechat/src/common/weechat.c44
-rw-r--r--weechat/src/common/weechat.h2
-rw-r--r--weechat/src/gui/curses/gui-display.c13
-rw-r--r--weechat/src/gui/curses/gui-input.c4
-rw-r--r--weechat/src/gui/gui-common.c23
-rw-r--r--weechat/src/gui/gui.h1
-rw-r--r--weechat/src/irc/irc-server.c3
-rw-r--r--weechat/src/plugins/plugins.c1
26 files changed, 314 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index 15621b2cb..8edcae283 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
-ChangeLog - 2005-01-27
+ChangeLog - 2005-02-01
Version 0.1.0 (under dev!):
@@ -11,11 +11,6 @@ Version 0.1.0 (under dev!):
* improved completion: now completes commands arguments (IRC and internal),
when only one completion matches, completion mechanism is stoped (to
complete command arg for example)
- * fixed colors bug: removed "gray" color (replaced by "default"), colors are
- ok when terminal has white (or light) background
- * fixed crash when multiple servers and big messages received from server
- * fixed crash when closing some private buffers
- * fixed crash when unknown section with option(s) in config file
* improved /set command: empty strings are allowed, new colors, server
options can be changed while WeeChat is running
* added default away/part/quit messages in config file
@@ -23,6 +18,12 @@ Version 0.1.0 (under dev!):
"irc_display_away"
* server messages & errors are all prefixed (by 3 chars, like '-@-')
* added new options for charset: look_charset_decode and look_charset_encode
+ * fixed many memory leaks
+ * fixed colors bug: removed "gray" color (replaced by "default"), colors are
+ ok when terminal has white (or light) background
+ * fixed crash when multiple servers and big messages received from server
+ * fixed crash when closing some private buffers
+ * fixed crash when unknown section with option(s) in config file
* fixed /op, /deop, /voice, /devoice (now ok with many nicks)
* fixed /me command (now ok without parameter)
* fixed /away command (now ok if not away)
diff --git a/src/common/command.c b/src/common/command.c
index b24d14e3a..7b7cb68ba 100644
--- a/src/common/command.c
+++ b/src/common/command.c
@@ -146,6 +146,19 @@ command_index_build ()
}
/*
+ * command_index_free: remove all commands in index
+ */
+
+void
+command_index_free ()
+{
+ while (index_commands)
+ {
+ weelist_remove (&index_commands, &last_index_command, index_commands);
+ }
+}
+
+/*
* alias_search: search an alias
*/
@@ -307,6 +320,17 @@ alias_free (t_weechat_alias *alias)
}
/*
+ * alias_free_all: free all alias
+ */
+
+void
+alias_free_all ()
+{
+ while (weechat_alias)
+ alias_free (weechat_alias);
+}
+
+/*
* explode_string: explode a string according to separators
*/
diff --git a/src/common/command.h b/src/common/command.h
index 44a2a913b..474f3c10c 100644
--- a/src/common/command.h
+++ b/src/common/command.h
@@ -56,7 +56,9 @@ extern t_weelist *index_commands;
extern t_weelist *last_index_command;
extern void command_index_build ();
+extern void command_index_free ();
extern t_weechat_alias *alias_new (char *, char *);
+extern void alias_free_all ();
extern int exec_weechat_command (t_irc_server *, char *);
extern void user_command (t_irc_server *, char *);
extern int weechat_cmd_alias (char *);
diff --git a/src/common/history.c b/src/common/history.c
index 116e7f31c..ece23fdd7 100644
--- a/src/common/history.c
+++ b/src/common/history.c
@@ -136,3 +136,50 @@ history_add (void *buffer, char *string)
}
}
}
+
+/*
+ * history_general_free: free general history
+ */
+
+void
+history_general_free ()
+{
+ t_history *ptr_history;
+
+ while (history_general)
+ {
+ ptr_history = history_general->next_history;
+ if (history_general->text)
+ free (history_general->text);
+ free (history_general);
+ history_general = ptr_history;
+ }
+ history_general = NULL;
+ history_general_last = NULL;
+ history_general_ptr = NULL;
+ num_history_general = 0;
+}
+
+
+/*
+ * history_buffer_free: free history for a buffer
+ */
+
+void
+history_buffer_free (void *buffer)
+{
+ t_history *ptr_history;
+
+ while (((t_gui_buffer *)(buffer))->history)
+ {
+ ptr_history = ((t_gui_buffer *)(buffer))->history->next_history;
+ if (((t_gui_buffer *)(buffer))->history->text)
+ free (((t_gui_buffer *)(buffer))->history->text);
+ free (((t_gui_buffer *)(buffer))->history);
+ ((t_gui_buffer *)(buffer))->history = ptr_history;
+ }
+ ((t_gui_buffer *)(buffer))->history = NULL;
+ ((t_gui_buffer *)(buffer))->last_history = NULL;
+ ((t_gui_buffer *)(buffer))->ptr_history = NULL;
+ ((t_gui_buffer *)(buffer))->num_history = 0;
+}
diff --git a/src/common/history.h b/src/common/history.h
index 652d206ca..9be1b40e8 100644
--- a/src/common/history.h
+++ b/src/common/history.h
@@ -31,5 +31,7 @@ struct t_history
};
extern void history_add (void *, char *);
+extern void history_general_free ();
+extern void history_buffer_free (void *);
#endif /* history.h */
diff --git a/src/common/weechat.c b/src/common/weechat.c
index b5629268a..c1e85e4e0 100644
--- a/src/common/weechat.c
+++ b/src/common/weechat.c
@@ -60,9 +60,9 @@
#include "../plugins/plugins.h"
-int quit_weechat; /* = 1 if quit request from user... why ? :'( */
-char *weechat_home; /* WeeChat home dir. (example: /home/toto/.weechat) */
-FILE *weechat_log_file; /* WeeChat log file (~/.weechat/weechat.log) */
+int quit_weechat; /* = 1 if quit request from user... why ? :'( */
+char *weechat_home = NULL; /* WeeChat home dir. (example: /home/toto/.weechat) */
+FILE *weechat_log_file = NULL; /* WeeChat log file (~/.weechat/weechat.log) */
char *local_charset = NULL; /* local charset, for example: ISO-8859-1 */
@@ -264,26 +264,26 @@ wee_parse_args (int argc, char *argv[])
|| (strcmp (argv[i], "--config") == 0))
{
wee_display_config_options ();
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strcmp (argv[i], "-h") == 0)
|| (strcmp (argv[i], "--help") == 0))
{
printf ("\n" WEE_USAGE1, argv[0], argv[0]);
printf ("%s", WEE_USAGE2);
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strcmp (argv[i], "-l") == 0)
|| (strcmp (argv[i], "--license") == 0))
{
printf ("\n%s%s", WEE_LICENSE);
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strcmp (argv[i], "-v") == 0)
|| (strcmp (argv[i], "--version") == 0))
{
printf (PACKAGE_VERSION "\n");
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strncasecmp (argv[i], "irc://", 6) == 0))
{
@@ -358,7 +358,7 @@ wee_create_home_dirs ()
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
- exit (EXIT_FAILURE);
+ wee_shutdown (EXIT_FAILURE);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
@@ -367,7 +367,7 @@ wee_create_home_dirs ()
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
- exit (EXIT_FAILURE);
+ wee_shutdown (EXIT_FAILURE);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
@@ -377,7 +377,7 @@ wee_create_home_dirs ()
{
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"),
WEECHAT_ERROR);
- exit (EXIT_FAILURE);
+ wee_shutdown (EXIT_FAILURE);
}
dir_length = strlen (weechat_home) + 64;
@@ -509,18 +509,32 @@ weechat_welcome_message ()
}
/*
- * wee_shutdown: shutdown WeeChat
+ * wee_gui_shutdown: shutdown WeeChat GUI
*/
void
-wee_shutdown ()
+wee_gui_shutdown ()
{
dcc_end ();
server_free_all ();
gui_end ();
+}
+
+/*
+ * wee_shutdown: shutdown WeeChat
+ */
+
+void
+wee_shutdown (int return_code)
+{
+ if (weechat_home)
+ free (weechat_home);
if (weechat_log_file)
fclose (weechat_log_file);
- exit (EXIT_SUCCESS);
+ if (local_charset)
+ free (local_charset);
+ alias_free_all ();
+ exit (return_code);
}
/*
@@ -572,7 +586,9 @@ main (int argc, char *argv[])
plugin_end (); /* end plugin interface(s) */
server_disconnect_all (); /* disconnect from all servers */
(void) config_write (NULL); /* save config file */
- wee_shutdown (); /* quit WeeChat (oh no, why?) */
+ command_index_free (); /* free commands index */
+ wee_gui_shutdown (); /* shut down WeeChat GUI */
+ wee_shutdown (EXIT_SUCCESS); /* quit WeeChat (oh no, why?) */
return EXIT_SUCCESS; /* make gcc happy (never executed) */
}
diff --git a/src/common/weechat.h b/src/common/weechat.h
index 95e5a1fad..16504a3d3 100644
--- a/src/common/weechat.h
+++ b/src/common/weechat.h
@@ -105,6 +105,6 @@ extern char *local_charset;
extern char *weechat_convert_encoding (char *, char *, char *);
extern long get_timeval_diff (struct timeval *, struct timeval *);
extern void wee_log_printf (char *, ...);
-extern void wee_shutdown ();
+extern void wee_shutdown (int);
#endif /* weechat.h */
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 377837025..1fe7ea1e9 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -1947,6 +1947,19 @@ gui_end ()
gui_buffer_free (gui_buffers, 0);
}
+ /* delete all windows */
+ while (gui_windows)
+ {
+ gui_window_free (gui_windows);
+ }
+
+ /* delete general history */
+ history_general_free ();
+
+ /* delete infobar messages */
+ while (gui_infobar)
+ gui_infobar_remove ();
+
/* end of curses output */
refresh ();
endwin ();
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index a0efdcc20..cb222f9fb 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -89,6 +89,7 @@ gui_read_keyb ()
/* remove last infobar message */
case KEY_F(10):
gui_infobar_remove ();
+ gui_draw_buffer_infobar (gui_current_window->buffer, 1);
break;
/* cursor up */
case KEY_UP:
@@ -666,7 +667,10 @@ gui_main_loop ()
{
gui_infobar->remaining_time--;
if (gui_infobar->remaining_time == 0)
+ {
gui_infobar_remove ();
+ gui_draw_buffer_infobar (gui_current_window->buffer, 1);
+ }
}
check_away++;
if (check_away >= CHECK_AWAY_DELAY)
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 842bf4c74..88722b0c8 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -330,6 +330,26 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...)
}
/*
+ * gui_window_free: delete a window
+ */
+
+void
+gui_window_free (t_gui_window *window)
+{
+ /* remove window from windows list */
+ if (window->prev_window)
+ window->prev_window->next_window = window->next_window;
+ if (window->next_window)
+ window->next_window->prev_window = window->prev_window;
+ if (gui_windows == window)
+ gui_windows = window->next_window;
+ if (last_gui_window == window)
+ last_gui_window = window->prev_window;
+
+ free (window);
+}
+
+/*
* gui_infobar_remove: remove last displayed message in infobar
*/
@@ -345,7 +365,6 @@ gui_infobar_remove ()
free (gui_infobar->text);
free (gui_infobar);
gui_infobar = new_infobar;
- gui_draw_buffer_infobar (gui_current_window->buffer, 1);
}
}
@@ -423,6 +442,8 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
completion_free (&(buffer->completion));
+ history_buffer_free (buffer);
+
/* remove buffer from buffers list */
if (buffer->prev_buffer)
buffer->prev_buffer->next_buffer = buffer->next_buffer;
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 3ad47f4b3..756a807a4 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -255,6 +255,7 @@ extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
extern void gui_buffer_clear (t_gui_buffer *);
extern void gui_buffer_clear_all ();
extern void gui_infobar_printf (int, int, char *, ...);
+extern void gui_window_free (t_gui_window *);
extern void gui_infobar_remove ();
extern void gui_buffer_free (t_gui_buffer *, int);
extern t_gui_line *gui_new_line (t_gui_buffer *);
diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c
index 1581bf931..c0767d666 100644
--- a/src/irc/irc-server.c
+++ b/src/irc/irc-server.c
@@ -596,6 +596,9 @@ server_msgq_flush ()
WEECHAT_ERROR, command, args);
break;
}
+
+ if (command)
+ free (command);
}
free (entire_line);
diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c
index 0bbb59146..e9f25354d 100644
--- a/src/plugins/plugins.c
+++ b/src/plugins/plugins.c
@@ -92,6 +92,7 @@ plugin_auto_load (int plugin_type, char *directory)
plugin_load (plugin_type, entry->d_name);
}
}
+ closedir (dir);
}
/* restore working directory */
diff --git a/weechat/ChangeLog b/weechat/ChangeLog
index 15621b2cb..8edcae283 100644
--- a/weechat/ChangeLog
+++ b/weechat/ChangeLog
@@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
-ChangeLog - 2005-01-27
+ChangeLog - 2005-02-01
Version 0.1.0 (under dev!):
@@ -11,11 +11,6 @@ Version 0.1.0 (under dev!):
* improved completion: now completes commands arguments (IRC and internal),
when only one completion matches, completion mechanism is stoped (to
complete command arg for example)
- * fixed colors bug: removed "gray" color (replaced by "default"), colors are
- ok when terminal has white (or light) background
- * fixed crash when multiple servers and big messages received from server
- * fixed crash when closing some private buffers
- * fixed crash when unknown section with option(s) in config file
* improved /set command: empty strings are allowed, new colors, server
options can be changed while WeeChat is running
* added default away/part/quit messages in config file
@@ -23,6 +18,12 @@ Version 0.1.0 (under dev!):
"irc_display_away"
* server messages & errors are all prefixed (by 3 chars, like '-@-')
* added new options for charset: look_charset_decode and look_charset_encode
+ * fixed many memory leaks
+ * fixed colors bug: removed "gray" color (replaced by "default"), colors are
+ ok when terminal has white (or light) background
+ * fixed crash when multiple servers and big messages received from server
+ * fixed crash when closing some private buffers
+ * fixed crash when unknown section with option(s) in config file
* fixed /op, /deop, /voice, /devoice (now ok with many nicks)
* fixed /me command (now ok without parameter)
* fixed /away command (now ok if not away)
diff --git a/weechat/src/common/command.c b/weechat/src/common/command.c
index b24d14e3a..7b7cb68ba 100644
--- a/weechat/src/common/command.c
+++ b/weechat/src/common/command.c
@@ -146,6 +146,19 @@ command_index_build ()
}
/*
+ * command_index_free: remove all commands in index
+ */
+
+void
+command_index_free ()
+{
+ while (index_commands)
+ {
+ weelist_remove (&index_commands, &last_index_command, index_commands);
+ }
+}
+
+/*
* alias_search: search an alias
*/
@@ -307,6 +320,17 @@ alias_free (t_weechat_alias *alias)
}
/*
+ * alias_free_all: free all alias
+ */
+
+void
+alias_free_all ()
+{
+ while (weechat_alias)
+ alias_free (weechat_alias);
+}
+
+/*
* explode_string: explode a string according to separators
*/
diff --git a/weechat/src/common/command.h b/weechat/src/common/command.h
index 44a2a913b..474f3c10c 100644
--- a/weechat/src/common/command.h
+++ b/weechat/src/common/command.h
@@ -56,7 +56,9 @@ extern t_weelist *index_commands;
extern t_weelist *last_index_command;
extern void command_index_build ();
+extern void command_index_free ();
extern t_weechat_alias *alias_new (char *, char *);
+extern void alias_free_all ();
extern int exec_weechat_command (t_irc_server *, char *);
extern void user_command (t_irc_server *, char *);
extern int weechat_cmd_alias (char *);
diff --git a/weechat/src/common/history.c b/weechat/src/common/history.c
index 116e7f31c..ece23fdd7 100644
--- a/weechat/src/common/history.c
+++ b/weechat/src/common/history.c
@@ -136,3 +136,50 @@ history_add (void *buffer, char *string)
}
}
}
+
+/*
+ * history_general_free: free general history
+ */
+
+void
+history_general_free ()
+{
+ t_history *ptr_history;
+
+ while (history_general)
+ {
+ ptr_history = history_general->next_history;
+ if (history_general->text)
+ free (history_general->text);
+ free (history_general);
+ history_general = ptr_history;
+ }
+ history_general = NULL;
+ history_general_last = NULL;
+ history_general_ptr = NULL;
+ num_history_general = 0;
+}
+
+
+/*
+ * history_buffer_free: free history for a buffer
+ */
+
+void
+history_buffer_free (void *buffer)
+{
+ t_history *ptr_history;
+
+ while (((t_gui_buffer *)(buffer))->history)
+ {
+ ptr_history = ((t_gui_buffer *)(buffer))->history->next_history;
+ if (((t_gui_buffer *)(buffer))->history->text)
+ free (((t_gui_buffer *)(buffer))->history->text);
+ free (((t_gui_buffer *)(buffer))->history);
+ ((t_gui_buffer *)(buffer))->history = ptr_history;
+ }
+ ((t_gui_buffer *)(buffer))->history = NULL;
+ ((t_gui_buffer *)(buffer))->last_history = NULL;
+ ((t_gui_buffer *)(buffer))->ptr_history = NULL;
+ ((t_gui_buffer *)(buffer))->num_history = 0;
+}
diff --git a/weechat/src/common/history.h b/weechat/src/common/history.h
index 652d206ca..9be1b40e8 100644
--- a/weechat/src/common/history.h
+++ b/weechat/src/common/history.h
@@ -31,5 +31,7 @@ struct t_history
};
extern void history_add (void *, char *);
+extern void history_general_free ();
+extern void history_buffer_free (void *);
#endif /* history.h */
diff --git a/weechat/src/common/weechat.c b/weechat/src/common/weechat.c
index b5629268a..c1e85e4e0 100644
--- a/weechat/src/common/weechat.c
+++ b/weechat/src/common/weechat.c
@@ -60,9 +60,9 @@
#include "../plugins/plugins.h"
-int quit_weechat; /* = 1 if quit request from user... why ? :'( */
-char *weechat_home; /* WeeChat home dir. (example: /home/toto/.weechat) */
-FILE *weechat_log_file; /* WeeChat log file (~/.weechat/weechat.log) */
+int quit_weechat; /* = 1 if quit request from user... why ? :'( */
+char *weechat_home = NULL; /* WeeChat home dir. (example: /home/toto/.weechat) */
+FILE *weechat_log_file = NULL; /* WeeChat log file (~/.weechat/weechat.log) */
char *local_charset = NULL; /* local charset, for example: ISO-8859-1 */
@@ -264,26 +264,26 @@ wee_parse_args (int argc, char *argv[])
|| (strcmp (argv[i], "--config") == 0))
{
wee_display_config_options ();
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strcmp (argv[i], "-h") == 0)
|| (strcmp (argv[i], "--help") == 0))
{
printf ("\n" WEE_USAGE1, argv[0], argv[0]);
printf ("%s", WEE_USAGE2);
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strcmp (argv[i], "-l") == 0)
|| (strcmp (argv[i], "--license") == 0))
{
printf ("\n%s%s", WEE_LICENSE);
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strcmp (argv[i], "-v") == 0)
|| (strcmp (argv[i], "--version") == 0))
{
printf (PACKAGE_VERSION "\n");
- exit (EXIT_SUCCESS);
+ wee_shutdown (EXIT_SUCCESS);
}
else if ((strncasecmp (argv[i], "irc://", 6) == 0))
{
@@ -358,7 +358,7 @@ wee_create_home_dirs ()
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
- exit (EXIT_FAILURE);
+ wee_shutdown (EXIT_FAILURE);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
@@ -367,7 +367,7 @@ wee_create_home_dirs ()
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
- exit (EXIT_FAILURE);
+ wee_shutdown (EXIT_FAILURE);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
@@ -377,7 +377,7 @@ wee_create_home_dirs ()
{
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"),
WEECHAT_ERROR);
- exit (EXIT_FAILURE);
+ wee_shutdown (EXIT_FAILURE);
}
dir_length = strlen (weechat_home) + 64;
@@ -509,18 +509,32 @@ weechat_welcome_message ()
}
/*
- * wee_shutdown: shutdown WeeChat
+ * wee_gui_shutdown: shutdown WeeChat GUI
*/
void
-wee_shutdown ()
+wee_gui_shutdown ()
{
dcc_end ();
server_free_all ();
gui_end ();
+}
+
+/*
+ * wee_shutdown: shutdown WeeChat
+ */
+
+void
+wee_shutdown (int return_code)
+{
+ if (weechat_home)
+ free (weechat_home);
if (weechat_log_file)
fclose (weechat_log_file);
- exit (EXIT_SUCCESS);
+ if (local_charset)
+ free (local_charset);
+ alias_free_all ();
+ exit (return_code);
}
/*
@@ -572,7 +586,9 @@ main (int argc, char *argv[])
plugin_end (); /* end plugin interface(s) */
server_disconnect_all (); /* disconnect from all servers */
(void) config_write (NULL); /* save config file */
- wee_shutdown (); /* quit WeeChat (oh no, why?) */
+ command_index_free (); /* free commands index */
+ wee_gui_shutdown (); /* shut down WeeChat GUI */
+ wee_shutdown (EXIT_SUCCESS); /* quit WeeChat (oh no, why?) */
return EXIT_SUCCESS; /* make gcc happy (never executed) */
}
diff --git a/weechat/src/common/weechat.h b/weechat/src/common/weechat.h
index 95e5a1fad..16504a3d3 100644
--- a/weechat/src/common/weechat.h
+++ b/weechat/src/common/weechat.h
@@ -105,6 +105,6 @@ extern char *local_charset;
extern char *weechat_convert_encoding (char *, char *, char *);
extern long get_timeval_diff (struct timeval *, struct timeval *);
extern void wee_log_printf (char *, ...);
-extern void wee_shutdown ();
+extern void wee_shutdown (int);
#endif /* weechat.h */
diff --git a/weechat/src/gui/curses/gui-display.c b/weechat/src/gui/curses/gui-display.c
index 377837025..1fe7ea1e9 100644
--- a/weechat/src/gui/curses/gui-display.c
+++ b/weechat/src/gui/curses/gui-display.c
@@ -1947,6 +1947,19 @@ gui_end ()
gui_buffer_free (gui_buffers, 0);
}
+ /* delete all windows */
+ while (gui_windows)
+ {
+ gui_window_free (gui_windows);
+ }
+
+ /* delete general history */
+ history_general_free ();
+
+ /* delete infobar messages */
+ while (gui_infobar)
+ gui_infobar_remove ();
+
/* end of curses output */
refresh ();
endwin ();
diff --git a/weechat/src/gui/curses/gui-input.c b/weechat/src/gui/curses/gui-input.c
index a0efdcc20..cb222f9fb 100644
--- a/weechat/src/gui/curses/gui-input.c
+++ b/weechat/src/gui/curses/gui-input.c
@@ -89,6 +89,7 @@ gui_read_keyb ()
/* remove last infobar message */
case KEY_F(10):
gui_infobar_remove ();
+ gui_draw_buffer_infobar (gui_current_window->buffer, 1);
break;
/* cursor up */
case KEY_UP:
@@ -666,7 +667,10 @@ gui_main_loop ()
{
gui_infobar->remaining_time--;
if (gui_infobar->remaining_time == 0)
+ {
gui_infobar_remove ();
+ gui_draw_buffer_infobar (gui_current_window->buffer, 1);
+ }
}
check_away++;
if (check_away >= CHECK_AWAY_DELAY)
diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c
index 842bf4c74..88722b0c8 100644
--- a/weechat/src/gui/gui-common.c
+++ b/weechat/src/gui/gui-common.c
@@ -330,6 +330,26 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...)
}
/*
+ * gui_window_free: delete a window
+ */
+
+void
+gui_window_free (t_gui_window *window)
+{
+ /* remove window from windows list */
+ if (window->prev_window)
+ window->prev_window->next_window = window->next_window;
+ if (window->next_window)
+ window->next_window->prev_window = window->prev_window;
+ if (gui_windows == window)
+ gui_windows = window->next_window;
+ if (last_gui_window == window)
+ last_gui_window = window->prev_window;
+
+ free (window);
+}
+
+/*
* gui_infobar_remove: remove last displayed message in infobar
*/
@@ -345,7 +365,6 @@ gui_infobar_remove ()
free (gui_infobar->text);
free (gui_infobar);
gui_infobar = new_infobar;
- gui_draw_buffer_infobar (gui_current_window->buffer, 1);
}
}
@@ -423,6 +442,8 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
completion_free (&(buffer->completion));
+ history_buffer_free (buffer);
+
/* remove buffer from buffers list */
if (buffer->prev_buffer)
buffer->prev_buffer->next_buffer = buffer->next_buffer;
diff --git a/weechat/src/gui/gui.h b/weechat/src/gui/gui.h
index 3ad47f4b3..756a807a4 100644
--- a/weechat/src/gui/gui.h
+++ b/weechat/src/gui/gui.h
@@ -255,6 +255,7 @@ extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
extern void gui_buffer_clear (t_gui_buffer *);
extern void gui_buffer_clear_all ();
extern void gui_infobar_printf (int, int, char *, ...);
+extern void gui_window_free (t_gui_window *);
extern void gui_infobar_remove ();
extern void gui_buffer_free (t_gui_buffer *, int);
extern t_gui_line *gui_new_line (t_gui_buffer *);
diff --git a/weechat/src/irc/irc-server.c b/weechat/src/irc/irc-server.c
index 1581bf931..c0767d666 100644
--- a/weechat/src/irc/irc-server.c
+++ b/weechat/src/irc/irc-server.c
@@ -596,6 +596,9 @@ server_msgq_flush ()
WEECHAT_ERROR, command, args);
break;
}
+
+ if (command)
+ free (command);
}
free (entire_line);
diff --git a/weechat/src/plugins/plugins.c b/weechat/src/plugins/plugins.c
index 0bbb59146..e9f25354d 100644
--- a/weechat/src/plugins/plugins.c
+++ b/weechat/src/plugins/plugins.c
@@ -92,6 +92,7 @@ plugin_auto_load (int plugin_type, char *directory)
plugin_load (plugin_type, entry->d_name);
}
}
+ closedir (dir);
}
/* restore working directory */