diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-01-31 23:33:59 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-01-31 23:33:59 +0000 |
commit | 8921e45815b15d27976eb6f1bc8339d71eca640d (patch) | |
tree | 2e224ac97ed29ab21ab8f95396227a4d6b1e82c9 /src/common/history.c | |
parent | 74b83e52940e35a9a2f9ee6177775d067fef502c (diff) | |
download | weechat-8921e45815b15d27976eb6f1bc8339d71eca640d.zip |
Fixed many memory leaks
Diffstat (limited to 'src/common/history.c')
-rw-r--r-- | src/common/history.c | 47 |
1 files changed, 47 insertions, 0 deletions
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; +} |