diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-bar-window.c | 3 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 33 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 9 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-key.c | 3 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 3 | ||||
-rw-r--r-- | src/gui/gui-bar-item-custom.c | 6 | ||||
-rw-r--r-- | src/gui/gui-bar-item.c | 21 | ||||
-rw-r--r-- | src/gui/gui-bar-window.c | 12 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 42 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 96 | ||||
-rw-r--r-- | src/gui/gui-chat.c | 24 | ||||
-rw-r--r-- | src/gui/gui-color.c | 12 | ||||
-rw-r--r-- | src/gui/gui-completion.c | 30 | ||||
-rw-r--r-- | src/gui/gui-filter.c | 18 | ||||
-rw-r--r-- | src/gui/gui-focus.c | 30 | ||||
-rw-r--r-- | src/gui/gui-history.c | 18 | ||||
-rw-r--r-- | src/gui/gui-hotlist.c | 6 | ||||
-rw-r--r-- | src/gui/gui-input.c | 9 | ||||
-rw-r--r-- | src/gui/gui-key.c | 33 | ||||
-rw-r--r-- | src/gui/gui-layout.c | 18 | ||||
-rw-r--r-- | src/gui/gui-line.c | 48 | ||||
-rw-r--r-- | src/gui/gui-nick.c | 9 | ||||
-rw-r--r-- | src/gui/gui-nicklist.c | 6 | ||||
-rw-r--r-- | src/gui/gui-window.c | 9 |
24 files changed, 166 insertions, 332 deletions
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c index 0be0fb54b..0b02b6951 100644 --- a/src/gui/curses/gui-curses-bar-window.c +++ b/src/gui/curses/gui-curses-bar-window.c @@ -397,8 +397,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, (output) ? output : utf_char2); if (reverse_video) wattroff (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_REVERSE); - if (output) - free (output); + free (output); if (gui_window_current_emphasis) { diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 5ab93fcae..2af70a624 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -459,8 +459,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line, wattroff (GUI_WINDOW_OBJECTS(window)->win_chat, A_REVERSE); } - if (output) - free (output); + free (output); if (gui_window_current_emphasis) { @@ -764,8 +763,7 @@ gui_chat_display_day_changed (struct t_gui_window *window, 0, simulate, 0, 0); window->win_chat_cursor_x = window->win_chat_width; - if (message_with_color) - free (message_with_color); + free (message_with_color); } /* @@ -1240,8 +1238,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, if (window->win_chat_cursor_y < window->coords_size) window->coords[window->win_chat_cursor_y].prefix_x2 = window->win_chat_cursor_x - 1; - if (prefix_highlighted) - free (prefix_highlighted); + free (prefix_highlighted); if (!simulate) { @@ -1371,8 +1368,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, simulate, 0, 0); } } - if (ptr_prefix) - free (ptr_prefix); + free (ptr_prefix); } /* @@ -1652,12 +1648,9 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, &lines_displayed, simulate); } - if (message_nick_offline) - free (message_nick_offline); - if (message_with_tags) - free (message_with_tags); - if (message_with_search) - free (message_with_search); + free (message_nick_offline); + free (message_with_tags); + free (message_with_search); /* display message if day has changed after this line */ if ((line->data->date != 0) @@ -1809,10 +1802,8 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line, gui_window_clrtoeol (GUI_WINDOW_OBJECTS(window)->win_chat); } - if (message_with_tags) - free (message_with_tags); - if (message_with_search) - free (message_with_search); + free (message_with_tags); + free (message_with_search); } /* @@ -2163,10 +2154,8 @@ gui_chat_get_bare_line (struct t_gui_line *line) } end: - if (prefix) - free (prefix); - if (message) - free (message); + free (prefix); + free (message); return str_line; } diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index af71bfd9a..7a8b0ebc9 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -763,10 +763,8 @@ gui_color_init_pairs_weechat () init_pair (i, i, -1); } } - if (foregrounds) - free (foregrounds); - if (backgrounds) - free (backgrounds); + free (foregrounds); + free (backgrounds); } } @@ -1533,8 +1531,7 @@ gui_color_palette_free (struct t_gui_color_palette *color_palette) if (!color_palette) return; - if (color_palette->alias) - free (color_palette->alias); + free (color_palette->alias); free (color_palette); } diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c index d82ce7897..ca887b7b9 100644 --- a/src/gui/curses/gui-curses-key.c +++ b/src/gui/curses/gui-curses-key.c @@ -482,8 +482,7 @@ gui_key_flush (int paste) } } - if (input_old) - free (input_old); + free (input_old); } /* prepare incomplete UTF-8 char for next iteration */ diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 2050f1b43..b774f28df 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -498,8 +498,7 @@ gui_main_end (int clean_exit) gui_filter_free_all (); /* free clipboard buffer */ - if (gui_input_clipboard) - free (gui_input_clipboard); + free (gui_input_clipboard); /* delete layouts */ gui_layout_remove_all (); diff --git a/src/gui/gui-bar-item-custom.c b/src/gui/gui-bar-item-custom.c index 15b217f63..206eb96b5 100644 --- a/src/gui/gui-bar-item-custom.c +++ b/src/gui/gui-bar-item-custom.c @@ -611,8 +611,7 @@ gui_bar_item_custom_free_data (struct t_gui_bar_item_custom *item) { int i; - if (item->name) - free (item->name); + free (item->name); for (i = 0; i < GUI_BAR_ITEM_CUSTOM_NUM_OPTIONS; i++) { if (item->options[i]) @@ -654,8 +653,7 @@ gui_bar_item_custom_free (struct t_gui_bar_item_custom *item) gui_bar_item_update (name); - if (name) - free (name); + free (name); } /* diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index d3ccf9265..3e6db5e7f 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -442,8 +442,7 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window, ptr_item->name, plugin_get_name (ptr_item->plugin), str_diff); - if (str_diff) - free (str_diff); + free (str_diff); } } } @@ -459,8 +458,7 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window, result = string_dyn_alloc (128); if (!result) { - if (item_value) - free (item_value); + free (item_value); return NULL; } @@ -532,8 +530,7 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window, string_dyn_concat (result, bar->items_suffix[item][subitem], -1); } - if (item_value) - free (item_value); + free (item_value); return string_dyn_free (result, 0); } @@ -730,10 +727,8 @@ gui_bar_item_free (struct t_gui_bar_item *item) last_gui_bar_item = item->prev_item; /* free data */ - if (item->name) - free (item->name); - if (item->build_callback_data) - free (item->build_callback_data); + free (item->name); + free (item->build_callback_data); free (item); } @@ -1016,8 +1011,7 @@ gui_bar_item_input_text_cb (const void *pointer, void *data, "input_text_display_with_cursor", str_buffer, (ptr_input) ? ptr_input : ""); - if (ptr_input) - free (ptr_input); + free (ptr_input); ptr_input = ptr_input2; } @@ -1734,8 +1728,7 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data, } } - if (buffer_without_name_displayed) - free (buffer_without_name_displayed); + free (buffer_without_name_displayed); hotlist_suffix = CONFIG_STRING(config_look_hotlist_suffix); if (hotlist_suffix[0] diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c index 7294937fa..f2b0e3750 100644 --- a/src/gui/gui-bar-window.c +++ b/src/gui/gui-bar-window.c @@ -516,8 +516,7 @@ error: { for (i = 0; i < bar_window->items_count; i++) { - if (bar_window->items_content[i]) - free (bar_window->items_content[i]); + free (bar_window->items_content[i]); } free (bar_window->items_content); bar_window->items_content = NULL; @@ -526,8 +525,7 @@ error: { for (i = 0; i < bar_window->items_count; i++) { - if (bar_window->items_num_lines[i]) - free (bar_window->items_num_lines[i]); + free (bar_window->items_num_lines[i]); } free (bar_window->items_num_lines); bar_window->items_num_lines = NULL; @@ -536,8 +534,7 @@ error: { for (i = 0; i < bar_window->items_count; i++) { - if (bar_window->items_refresh_needed[i]) - free (bar_window->items_refresh_needed[i]); + free (bar_window->items_refresh_needed[i]); } free (bar_window->items_refresh_needed); bar_window->items_refresh_needed = NULL; @@ -814,8 +811,7 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window, (item_value) ? item_value : ptr_content, -1); first_sub_item = 0; - if (item_value) - free (item_value); + free (item_value); if (item_is_spacer) (*num_spacers)++; else diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 097fd979d..37b943be9 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -418,8 +418,7 @@ gui_bar_check_conditions (struct t_gui_bar *bar, result = eval_expression (conditions, pointers, extra_vars, options); rc = eval_is_true (result); - if (result) - free (result); + free (result); if (pointers) hashtable_free (pointers); if (extra_vars) @@ -448,8 +447,7 @@ gui_bar_check_conditions (struct t_gui_bar *bar, else rc = 1; - if (str_displayed) - free (str_displayed); + free (str_displayed); return rc; } @@ -693,23 +691,15 @@ gui_bar_free_items_arrays (struct t_gui_bar *bar) string_free_split (bar->items_array[i]); for (j = 0; j < bar->items_subcount[i]; j++) { - if (bar->items_buffer[i][j]) - free (bar->items_buffer[i][j]); - if (bar->items_prefix[i][j]) - free (bar->items_prefix[i][j]); - if (bar->items_name[i][j]) - free (bar->items_name[i][j]); - if (bar->items_suffix[i][j]) - free (bar->items_suffix[i][j]); + free (bar->items_buffer[i][j]); + free (bar->items_prefix[i][j]); + free (bar->items_name[i][j]); + free (bar->items_suffix[i][j]); } - if (bar->items_buffer[i]) - free (bar->items_buffer[i]); - if (bar->items_prefix[i]) - free (bar->items_prefix[i]); - if (bar->items_name[i]) - free (bar->items_name[i]); - if (bar->items_suffix[i]) - free (bar->items_suffix[i]); + free (bar->items_buffer[i]); + free (bar->items_prefix[i]); + free (bar->items_name[i]); + free (bar->items_suffix[i]); } if (bar->items_array) { @@ -1220,8 +1210,7 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name) config_file_option_rename (bar->options[i], option_name); } - if (bar->name) - free (bar->name); + free (bar->name); bar->name = strdup (name); } @@ -1918,8 +1907,7 @@ gui_bar_use_temp_bars () { next_temp_bar = gui_temp_bars->next_bar; - if (gui_temp_bars->name) - free (gui_temp_bars->name); + free (gui_temp_bars->name); free (gui_temp_bars); gui_temp_bars = next_temp_bar; @@ -2191,8 +2179,7 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window, } } - if (str) - free (str); + free (str); return 1; } @@ -2229,8 +2216,7 @@ gui_bar_free (struct t_gui_bar *bar) last_gui_bar = bar->prev_bar; /* free data */ - if (bar->name) - free (bar->name); + free (bar->name); for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++) { if (bar->options[i]) diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index d7edf0c90..938c7c21c 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -240,8 +240,7 @@ gui_buffer_build_full_name (struct t_gui_buffer *buffer) if (!buffer) return; - if (buffer->full_name) - free (buffer->full_name); + free (buffer->full_name); length = strlen (gui_buffer_get_plugin_name (buffer)) + 1 + strlen (buffer->name) + 1; buffer->full_name = malloc (length); @@ -1277,8 +1276,7 @@ gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer, } if (!result2) { - if (result) - free (result); + free (result); free (local_var); return NULL; } @@ -1629,12 +1627,10 @@ gui_buffer_set_name (struct t_gui_buffer *buffer, const char *name) * save the old full name so that hooks on signal "buffer_renamed" * can read the old name */ - if (buffer->old_full_name) - free (buffer->old_full_name); + free (buffer->old_full_name); buffer->old_full_name = strdup (buffer->full_name); - if (buffer->name) - free (buffer->name); + free (buffer->name); buffer->name = strdup (name); gui_buffer_build_full_name (buffer); @@ -1743,8 +1739,7 @@ gui_buffer_set_title (struct t_gui_buffer *buffer, const char *new_title) return; } - if (buffer->title) - free (buffer->title); + free (buffer->title); buffer->title = (new_title && new_title[0]) ? strdup (new_title) : NULL; (void) gui_buffer_send_signal (buffer, @@ -1825,8 +1820,7 @@ gui_buffer_set_highlight_words (struct t_gui_buffer *buffer, if (!buffer) return; - if (buffer->highlight_words) - free (buffer->highlight_words); + free (buffer->highlight_words); buffer->highlight_words = (new_highlight_words && new_highlight_words[0]) ? strdup (new_highlight_words) : NULL; } @@ -3690,8 +3684,7 @@ gui_buffer_close (struct t_gui_buffer *buffer) } gui_hotlist_remove_buffer (buffer, 1); - if (buffer->hotlist_removed) - free (buffer->hotlist_removed); + free (buffer->hotlist_removed); if (gui_hotlist_initial_buffer == buffer) gui_hotlist_initial_buffer = NULL; @@ -3709,10 +3702,8 @@ gui_buffer_close (struct t_gui_buffer *buffer) /* free all lines */ gui_line_free_all (buffer); - if (buffer->own_lines) - free (buffer->own_lines); - if (buffer->mixed_lines) - free (buffer->mixed_lines); + free (buffer->own_lines); + free (buffer->mixed_lines); /* free some data */ gui_buffer_undo_free_all (buffer); @@ -3727,59 +3718,42 @@ gui_buffer_close (struct t_gui_buffer *buffer) &buffer->keys_count, 0); gui_buffer_local_var_remove_all (buffer); hashtable_free (buffer->local_variables); - if (buffer->plugin_name_for_upgrade) - free (buffer->plugin_name_for_upgrade); - if (buffer->name) - free (buffer->name); - if (buffer->full_name) - free (buffer->full_name); - if (buffer->old_full_name) - free (buffer->old_full_name); - if (buffer->short_name) - free (buffer->short_name); - if (buffer->title) - free (buffer->title); - if (buffer->input_buffer) - free (buffer->input_buffer); - if (buffer->input_undo_snap) - free (buffer->input_undo_snap); - if (buffer->text_search_input) - free (buffer->text_search_input); + free (buffer->plugin_name_for_upgrade); + free (buffer->name); + free (buffer->full_name); + free (buffer->old_full_name); + free (buffer->short_name); + free (buffer->title); + free (buffer->input_buffer); + free (buffer->input_undo_snap); + free (buffer->text_search_input); if (buffer->text_search_regex_compiled) { regfree (buffer->text_search_regex_compiled); free (buffer->text_search_regex_compiled); } - if (buffer->highlight_words) - free (buffer->highlight_words); - if (buffer->highlight_disable_regex) - free (buffer->highlight_disable_regex); + free (buffer->highlight_words); + free (buffer->highlight_disable_regex); if (buffer->highlight_disable_regex_compiled) { regfree (buffer->highlight_disable_regex_compiled); free (buffer->highlight_disable_regex_compiled); } - if (buffer->highlight_regex) - free (buffer->highlight_regex); + free (buffer->highlight_regex); if (buffer->highlight_regex_compiled) { regfree (buffer->highlight_regex_compiled); free (buffer->highlight_regex_compiled); } - if (buffer->highlight_tags_restrict) - free (buffer->highlight_tags_restrict); + free (buffer->highlight_tags_restrict); if (buffer->highlight_tags_restrict_array) string_free_split_tags (buffer->highlight_tags_restrict_array); - if (buffer->highlight_tags) - free (buffer->highlight_tags); + free (buffer->highlight_tags); if (buffer->highlight_tags_array) string_free_split_tags (buffer->highlight_tags_array); - if (buffer->input_callback_data) - free (buffer->input_callback_data); - if (buffer->close_callback_data) - free (buffer->close_callback_data); - if (buffer->nickcmp_callback_data) - free (buffer->nickcmp_callback_data); + free (buffer->input_callback_data); + free (buffer->close_callback_data); + free (buffer->nickcmp_callback_data); /* remove buffer from buffers list */ if (buffer->prev_buffer) @@ -4880,8 +4854,7 @@ gui_buffer_undo_free (struct t_gui_buffer *buffer, } /* free data */ - if (undo->data) - free (undo->data); + free (undo->data); /* remove undo from list */ if (undo->prev_undo) @@ -4956,8 +4929,7 @@ gui_buffer_input_move_to_buffer (struct t_gui_buffer *from_buffer, return; /* move input_buffer */ - if (to_buffer->input_buffer) - free (to_buffer->input_buffer); + free (to_buffer->input_buffer); to_buffer->input_buffer = from_buffer->input_buffer; to_buffer->input_buffer_alloc = from_buffer->input_buffer_alloc; to_buffer->input_buffer_size = from_buffer->input_buffer_size; @@ -5526,10 +5498,8 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer) num_line, (prefix_without_colors) ? prefix_without_colors : "(null)", (message_without_colors) ? message_without_colors : "(null)"); - if (prefix_without_colors) - free (prefix_without_colors); - if (message_without_colors) - free (message_without_colors); + free (prefix_without_colors); + free (message_without_colors); tags = string_rebuild_split_string ((const char **)ptr_line->data->tags_array, ",", 0, -1); @@ -5537,8 +5507,7 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer) (tags) ? tags : "(none)", ptr_line->data->displayed, ptr_line->data->highlight); - if (tags) - free (tags); + free (tags); snprintf (buf, sizeof (buf), "%s", ctime (&ptr_line->data->date)); buf[strlen (buf) - 1] = '\0'; log_printf (" date: %lld = %s", @@ -5775,8 +5744,7 @@ gui_buffer_print_log () ptr_line->data->prefix); log_printf (" data: '%s'", ptr_line->data->message); - if (tags) - free (tags); + free (tags); ptr_line = ptr_line->next_line; } diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 1b8a19408..d69cc8df8 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -548,8 +548,7 @@ gui_chat_change_time_format () { if (ptr_line->data->date != 0) { - if (ptr_line->data->str_time) - free (ptr_line->data->str_time); + free (ptr_line->data->str_time); ptr_line->data->str_time = gui_chat_get_time_string ( ptr_line->data->date, ptr_line->data->date_usec, @@ -768,8 +767,7 @@ gui_chat_printf_datetime_tags_internal (struct t_gui_buffer *buffer, } new_line->data->prefix_length = gui_chat_strlen_screen ( new_line->data->prefix); - if (new_line->data->message) - free (new_line->data->message); + free (new_line->data->message); new_line->data->message = strdup (ptr_msg); } } @@ -784,12 +782,9 @@ gui_chat_printf_datetime_tags_internal (struct t_gui_buffer *buffer, gui_buffer_ask_chat_refresh (new_line->data->buffer, 1); - if (string) - free (string); - if (modifier_data) - free (modifier_data); - if (new_string) - free (new_string); + free (string); + free (modifier_data); + free (new_string); return; @@ -799,12 +794,9 @@ no_print: gui_line_free_data (new_line); free (new_line); } - if (string) - free (string); - if (modifier_data) - free (modifier_data); - if (new_string) - free (new_string); + free (string); + free (modifier_data); + free (new_string); } /* diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 23c8f9a71..a143dc5c8 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -528,12 +528,10 @@ gui_color_get_custom (const char *color_name) color_bg); } - if (str_fg) - free (str_fg); + free (str_fg); } - if (color_attr) - free (color_attr); + free (color_attr); return color[index_color]; } @@ -1187,8 +1185,7 @@ gui_color_decode_ansi_cb (void *data, const char *text) end: if (items) string_free_split (items); - if (text2) - free (text2); + free (text2); return (output) ? output : strdup (""); } @@ -1868,8 +1865,7 @@ gui_color_free (struct t_gui_color *color) if (!color) return; - if (color->string) - free (color->string); + free (color->string); free (color); } diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 6239137a9..a4b0cc669 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -99,8 +99,7 @@ gui_completion_word_free_cb (void *data, completion_word = (struct t_gui_completion_word *)pointer; - if (completion_word->word) - free (completion_word->word); + free (completion_word->word); free (completion_word); } @@ -211,16 +210,13 @@ gui_completion_partial_list_add (struct t_gui_completion *completion, void gui_completion_free_data (struct t_gui_completion *completion) { - if (completion->base_command) - free (completion->base_command); + free (completion->base_command); completion->base_command = NULL; - if (completion->base_word) - free (completion->base_word); + free (completion->base_word); completion->base_word = NULL; - if (completion->args) - free (completion->args); + free (completion->args); completion->args = NULL; if (completion->list) @@ -229,8 +225,7 @@ gui_completion_free_data (struct t_gui_completion *completion) completion->list = NULL; } - if (completion->word_found) - free (completion->word_found); + free (completion->word_found); completion->word_found = NULL; if (completion->partial_list) @@ -1265,8 +1260,7 @@ gui_completion_complete (struct t_gui_completion *completion) { if ((!completion->word_found) || word_found_seen) { - if (completion->word_found) - free (completion->word_found); + free (completion->word_found); completion->word_found = strdup (ptr_completion_word->word); completion->word_found_is_nick = ptr_completion_word->nick_completion; @@ -1468,8 +1462,7 @@ gui_completion_auto (struct t_gui_completion *completion) completion, (default_completion) ? default_completion : "", NULL); - if (default_completion) - free (default_completion); + free (default_completion); } gui_completion_complete (completion); } @@ -1495,8 +1488,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data, /* if new completion => look for base word */ if (real_position != completion->position) { - if (completion->word_found) - free (completion->word_found); + free (completion->word_found); completion->word_found = NULL; completion->word_found_is_nick = 0; gui_completion_find_context (completion, data, real_position); @@ -1509,8 +1501,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data, switch (completion->context) { case GUI_COMPLETION_NULL: - if (old_word_found) - free (old_word_found); + free (old_word_found); return 0; case GUI_COMPLETION_COMMAND: gui_completion_command (completion); @@ -1545,8 +1536,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data, utf8_strlen (completion->base_word); } } - if (old_word_found) - free (old_word_found); + free (old_word_found); return 1; } diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c index e28f8be17..5ec2051e2 100644 --- a/src/gui/gui-filter.c +++ b/src/gui/gui-filter.c @@ -445,8 +445,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name, _("invalid regular expression (%s)"), buf); gui_filter_new_error (name, str_error); - if (regex_prefix) - free (regex_prefix); + free (regex_prefix); if (regex1) { regfree (regex1); @@ -458,8 +457,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name, } } - if (regex_prefix) - free (regex_prefix); + free (regex_prefix); } /* create new filter */ @@ -540,18 +538,14 @@ gui_filter_free (struct t_gui_filter *filter) WEECHAT_HOOK_SIGNAL_POINTER, filter); /* free data */ - if (filter->name) - free (filter->name); - if (filter->buffer_name) - free (filter->buffer_name); + free (filter->name); + free (filter->buffer_name); if (filter->buffers) string_free_split (filter->buffers); - if (filter->tags) - free (filter->tags); + free (filter->tags); if (filter->tags_array) string_free_split_tags (filter->tags_array); - if (filter->regex) - free (filter->regex); + free (filter->regex); if (filter->regex_prefix) { regfree (filter->regex_prefix); diff --git a/src/gui/gui-focus.c b/src/gui/gui-focus.c index 27d7ebf06..f61cf61fd 100644 --- a/src/gui/gui-focus.c +++ b/src/gui/gui-focus.c @@ -100,18 +100,12 @@ gui_focus_get_info (int x, int y) void gui_focus_free_info (struct t_gui_focus_info *focus_info) { - if (focus_info->chat_word) - free (focus_info->chat_word); - if (focus_info->chat_focused_line) - free (focus_info->chat_focused_line); - if (focus_info->chat_focused_line_bol) - free (focus_info->chat_focused_line_bol); - if (focus_info->chat_focused_line_eol) - free (focus_info->chat_focused_line_eol); - if (focus_info->chat_bol) - free (focus_info->chat_bol); - if (focus_info->chat_eol) - free (focus_info->chat_eol); + free (focus_info->chat_word); + free (focus_info->chat_focused_line); + free (focus_info->chat_focused_line_bol); + free (focus_info->chat_focused_line_eol); + free (focus_info->chat_bol); + free (focus_info->chat_eol); free (focus_info); } @@ -226,14 +220,10 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key) HASHTABLE_SET_STR_NOT_NULL("_chat_line_nick", nick); HASHTABLE_SET_STR_NOT_NULL("_chat_line_prefix", str_prefix); HASHTABLE_SET_STR_NOT_NULL("_chat_line_message", str_message); - if (str_time) - free (str_time); - if (str_prefix) - free (str_prefix); - if (str_tags) - free (str_tags); - if (str_message) - free (str_message); + free (str_time); + free (str_prefix); + free (str_tags); + free (str_message); } else { diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c index 2f6d2ec08..35eddc7c5 100644 --- a/src/gui/gui-history.c +++ b/src/gui/gui-history.c @@ -68,8 +68,7 @@ gui_history_buffer_remove_oldest (struct t_gui_buffer *buffer) if (buffer->ptr_history == buffer->last_history) buffer->ptr_history = ptr_history; ((buffer->last_history)->prev_history)->next_history = NULL; - if (buffer->last_history->text) - free (buffer->last_history->text); + free (buffer->last_history->text); free (buffer->last_history); buffer->last_history = ptr_history; @@ -140,8 +139,7 @@ gui_history_global_remove_oldest () if (gui_history_ptr == last_gui_history) gui_history_ptr = ptr_history; (last_gui_history->prev_history)->next_history = NULL; - if (last_gui_history->text) - free (last_gui_history->text); + free (last_gui_history->text); free (last_gui_history); last_gui_history = ptr_history; @@ -207,8 +205,7 @@ gui_history_add (struct t_gui_buffer *buffer, const char *string) gui_history_global_add ((string2) ? string2 : string); } - if (string2) - free (string2); + free (string2); } /* @@ -310,8 +307,7 @@ gui_history_global_free () while (gui_history) { ptr_history = gui_history->next_history; - if (gui_history->text) - free (gui_history->text); + free (gui_history->text); free (gui_history); gui_history = ptr_history; } @@ -337,8 +333,7 @@ gui_history_buffer_free (struct t_gui_buffer *buffer) while (buffer->history) { ptr_history = buffer->history->next_history; - if (buffer->history->text) - free (buffer->history->text); + free (buffer->history->text); free (buffer->history); buffer->history = ptr_history; } @@ -378,8 +373,7 @@ gui_history_hdata_history_update_cb (void *data, { /* update history */ ptr_history = (struct t_gui_history *)pointer; - if (ptr_history->text) - free (ptr_history->text); + free (ptr_history->text); ptr_history->text = strdup (text); } else diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c index 314f72509..50015b650 100644 --- a/src/gui/gui-hotlist.c +++ b/src/gui/gui-hotlist.c @@ -155,8 +155,7 @@ gui_hotlist_free (struct t_gui_hotlist **hotlist, if (save_removed_hotlist) { - if (ptr_hotlist->buffer->hotlist_removed) - free (ptr_hotlist->buffer->hotlist_removed); + free (ptr_hotlist->buffer->hotlist_removed); ptr_hotlist->buffer->hotlist_removed = gui_hotlist_dup (ptr_hotlist); ptr_hotlist->buffer->hotlist_removed->prev_hotlist = NULL; ptr_hotlist->buffer->hotlist_removed->next_hotlist = NULL; @@ -437,8 +436,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer, gui_hotlist_hashtable_add_conditions_vars, gui_hotlist_hashtable_add_conditions_options); rc = (value && (strcmp (value, "1") == 0)); - if (value) - free (value); + free (value); if (!rc) return NULL; } diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 6a6607c0d..7cfaf3349 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -1625,8 +1625,7 @@ gui_input_history_previous (struct t_gui_window *window, { /* replace text in history with current input */ window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0'; - if ((*ptr_history)->prev_history->text) - free ((*ptr_history)->prev_history->text); + free ((*ptr_history)->prev_history->text); (*ptr_history)->prev_history->text = strdup (window->buffer->input_buffer); } @@ -1675,8 +1674,7 @@ gui_input_history_next (struct t_gui_window *window, { /* replace text in history with current input */ window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0'; - if ((*ptr_history)->text) - free ((*ptr_history)->text); + free ((*ptr_history)->text); (*ptr_history)->text = strdup (window->buffer->input_buffer); *ptr_history = (*ptr_history)->prev_history; @@ -1892,8 +1890,7 @@ gui_input_insert (struct t_gui_buffer *buffer, const char *args) gui_input_text_changed_modifier_and_signal (buffer, 1, /* save undo */ 1); /* stop completion */ - if (args2) - free (args2); + free (args2); } /* diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index d1a450cb9..2ef35bcea 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -1161,10 +1161,8 @@ gui_key_set_areas (struct t_gui_key *key) &(key->area_name[area])); } - if (areas[0]) - free (areas[0]); - if (areas[1]) - free (areas[1]); + free (areas[0]); + free (areas[1]); } /* @@ -1413,8 +1411,7 @@ gui_key_option_change_cb (const void *pointer, void *data, if (!ptr_key) return; - if (ptr_key->command) - free (ptr_key->command); + free (ptr_key->command); ptr_key->command = strdup (CONFIG_STRING(option)); } @@ -1568,8 +1565,7 @@ error: key, gui_key_context_string[context]); } - if (key_fixed) - free (key_fixed); + free (key_fixed); if (ptr_option) config_file_option_free (ptr_option, 0); return NULL; @@ -2607,10 +2603,8 @@ end_no_input: rc = 0; end: - if (key_name) - free (key_name); - if (key_name_alias) - free (key_name_alias); + free (key_name); + free (key_name_alias); return rc; } @@ -2642,19 +2636,15 @@ gui_key_free (int context, } /* free memory */ - if (key->key) - free (key->key); + free (key->key); if (key->chunks) string_free_split (key->chunks); for (i = 0; i < 2; i++) { - if (key->area_name[i]) - free (key->area_name[i]); + free (key->area_name[i]); } - if (key->area_key) - free (key->area_key); - if (key->command) - free (key->command); + free (key->area_key); + free (key->command); /* remove key from keys list */ if (key->prev_key) @@ -3063,8 +3053,7 @@ gui_key_end () int context; /* free key buffer */ - if (gui_key_buffer) - free (gui_key_buffer); + free (gui_key_buffer); for (context = 0; context < GUI_KEY_NUM_CONTEXTS; context++) { diff --git a/src/gui/gui-layout.c b/src/gui/gui-layout.c index e95df3b35..31774c0c5 100644 --- a/src/gui/gui-layout.c +++ b/src/gui/gui-layout.c @@ -144,8 +144,7 @@ gui_layout_rename (struct t_gui_layout *layout, const char *new_name) if (!layout || !new_name || !new_name[0]) return; - if (layout->name) - free (layout->name); + free (layout->name); layout->name = strdup (new_name); } @@ -171,10 +170,8 @@ gui_layout_buffer_remove (struct t_gui_layout *layout, layout->last_layout_buffer = layout_buffer->prev_layout; /* free data */ - if (layout_buffer->plugin_name) - free (layout_buffer->plugin_name); - if (layout_buffer->buffer_name) - free (layout_buffer->buffer_name); + free (layout_buffer->plugin_name); + free (layout_buffer->buffer_name); free (layout_buffer); } @@ -389,10 +386,8 @@ gui_layout_window_remove (struct t_gui_layout_window *layout_window) gui_layout_window_remove (layout_window->child2); /* free data */ - if (layout_window->plugin_name) - free (layout_window->plugin_name); - if (layout_window->buffer_name) - free (layout_window->buffer_name); + free (layout_window->plugin_name); + free (layout_window->buffer_name); free (layout_window); } @@ -827,8 +822,7 @@ gui_layout_free (struct t_gui_layout *layout) gui_layout_window_remove (layout->layout_windows); /* free data */ - if (layout->name) - free (layout->name); + free (layout->name); free (layout); } diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index ee238881a..58a42a448 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -743,10 +743,8 @@ gui_line_match_regex (struct t_gui_line_data *line_data, regex_t *regex_prefix, match_message = 0; } - if (prefix) - free (prefix); - if (message) - free (message); + free (prefix); + free (message); return (match_prefix && match_message); } @@ -1053,8 +1051,7 @@ gui_line_has_highlight (struct t_gui_line *line) rc = string_has_highlight (ptr_msg_no_color, (highlight_words) ? highlight_words : line->data->buffer->highlight_words); - if (highlight_words) - free (highlight_words); + free (highlight_words); if (rc) goto end; @@ -1063,8 +1060,7 @@ gui_line_has_highlight (struct t_gui_line *line) rc = string_has_highlight (ptr_msg_no_color, (highlight_words) ? highlight_words : CONFIG_STRING(config_look_highlight)); - if (highlight_words) - free (highlight_words); + free (highlight_words); if (rc) goto end; @@ -1083,8 +1079,7 @@ gui_line_has_highlight (struct t_gui_line *line) } end: - if (msg_no_color) - free (msg_no_color); + free (msg_no_color); return rc; } @@ -1249,13 +1244,11 @@ gui_line_add_to_list (struct t_gui_lines *lines, void gui_line_free_data (struct t_gui_line *line) { - if (line->data->str_time) - free (line->data->str_time); + free (line->data->str_time); gui_line_tags_free (line->data); if (line->data->prefix) string_shared_free (line->data->prefix); - if (line->data->message) - free (line->data->message); + free (line->data->message); free (line->data); line->data = NULL; @@ -1732,8 +1725,7 @@ gui_line_hook_update (struct t_gui_line *line, if (error && !error[0] && (value >= 0)) { line->data->date = (time_t)value; - if (line->data->str_time) - free (line->data->str_time); + free (line->data->str_time); line->data->str_time = gui_chat_get_time_string ( line->data->date, line->data->date_usec, @@ -1749,8 +1741,7 @@ gui_line_hook_update (struct t_gui_line *line, if (error && !error[0] && (value >= 0) && (value <= 999999)) { line->data->date_usec = (int)value; - if (line->data->str_time) - free (line->data->str_time); + free (line->data->str_time); line->data->str_time = gui_chat_get_time_string ( line->data->date, line->data->date_usec, @@ -1780,8 +1771,7 @@ gui_line_hook_update (struct t_gui_line *line, ptr_value2 = hashtable_get (hashtable2, "str_time"); if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0))) { - if (line->data->str_time) - free (line->data->str_time); + free (line->data->str_time); line->data->str_time = (ptr_value2) ? strdup (ptr_value2) : NULL; } @@ -1818,11 +1808,9 @@ gui_line_hook_update (struct t_gui_line *line, if (pos_newline) pos_newline[0] = '\0'; } - if (line->data->message) - free (line->data->message); + free (line->data->message); line->data->message = (new_message) ? strdup (new_message) : NULL; - if (new_message) - free (new_message); + free (new_message); } max_notify_level = gui_line_get_max_notify_level (line); @@ -2090,8 +2078,7 @@ gui_line_clear (struct t_gui_line *line) line->data->prefix_length = 0; line->data->notify_level = 0; line->data->highlight = 0; - if (line->data->message) - free (line->data->message); + free (line->data->message); line->data->message = strdup (""); } @@ -2274,8 +2261,7 @@ gui_line_hdata_line_data_update_cb (void *data, if (value) { hdata_set (hdata, pointer, "date", value); - if (line_data->str_time) - free (line_data->str_time); + free (line_data->str_time); line_data->str_time = gui_chat_get_time_string ( line_data->date, line_data->date_usec, @@ -2291,8 +2277,7 @@ gui_line_hdata_line_data_update_cb (void *data, if (value) { hdata_set (hdata, pointer, "date_usec", value); - if (line_data->str_time) - free (line_data->str_time); + free (line_data->str_time); line_data->str_time = gui_chat_get_time_string ( line_data->date, line_data->date_usec, @@ -2355,8 +2340,7 @@ gui_line_hdata_line_data_update_cb (void *data, hdata_set (hdata, pointer, "message", new_value); rc++; update_coords = 1; - if (new_value) - free (new_value); + free (new_value); } if (rc > 0) diff --git a/src/gui/gui-nick.c b/src/gui/gui-nick.c index 0a4ee3c5e..f278904c9 100644 --- a/src/gui/gui-nick.c +++ b/src/gui/gui-nick.c @@ -326,10 +326,8 @@ end: result = strdup ((ptr_result) ? ptr_result : default_color); if (list_colors) string_free_split (list_colors); - if (nickname2) - free (nickname2); - if (nickname3) - free (nickname3); + free (nickname2); + free (nickname3); return result; } @@ -362,7 +360,6 @@ gui_nick_find_color (const char *nickname, int case_range, const char *colors) color = gui_nick_find_color_name (nickname, case_range, colors); ptr_result = gui_color_get_custom (color); - if (color) - free (color); + free (color); return (ptr_result) ? strdup (ptr_result) : NULL; } diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index 4d0443887..7e43f4275 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -620,8 +620,7 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer, gui_nicklist_send_signal ("nicklist_nick_removed", buffer, nick_removed); - if (nick_removed) - free (nick_removed); + free (nick_removed); } /* @@ -692,8 +691,7 @@ gui_nicklist_remove_group (struct t_gui_buffer *buffer, gui_nicklist_send_signal ("nicklist_group_removed", buffer, group_removed); - if (group_removed) - free (group_removed); + free (group_removed); } /* diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index 9db71a39e..e73d216ec 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -1056,17 +1056,14 @@ gui_window_free (struct t_gui_window *window) } /* free other data */ - if (window->layout_plugin_name) - free (window->layout_plugin_name); - if (window->layout_buffer_name) - free (window->layout_buffer_name); + free (window->layout_plugin_name); + free (window->layout_buffer_name); /* remove scroll list */ gui_window_scroll_free_all (window); /* free coords */ - if (window->coords) - free (window->coords); + free (window->coords); /* remove window from windows list */ if (window->prev_window) |