diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2016-03-21 18:11:21 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2016-03-21 18:11:21 +0100 |
commit | cf6aca1619c32422a43fa3d82e0674f6b7b49fe9 (patch) | |
tree | 65392ef12eab877f544fe306fe0abb98214ddebd /src/gui/curses | |
parent | 6d764b64c50adb19309a9de14bfeafac648ab47a (diff) | |
download | weechat-cf6aca1619c32422a43fa3d82e0674f6b7b49fe9.zip |
core: add pointer in some callbacks (closes #406)
This pointer is the first argument received by callbacks, and the
existing argument "data" is now automatically freed by WeeChat when the
object containing the callback is removed.
With this new pointer, the linked list of callbacks in scripts has been
removed. This will improve speed of scripts (using a lot of hooks),
reduce memory used by scripts and reduce time to unload scripts.
Following functions are affected in the C API:
* exec_on_files
* config_new
* config_new_section
* config_new_option
* hook_command
* hook_command_run
* hook_timer
* hook_fd
* hook_process
* hook_process_hashtable
* hook_connect
* hook_print
* hook_signal
* hook_hsignal
* hook_config
* hook_completion
* hook_modifier
* hook_info
* hook_info_hashtable
* hook_infolist
* hook_hdata
* hook_focus
* unhook_all_plugin
* buffer_new
* bar_item_new
* upgrade_new
* upgrade_read
Diffstat (limited to 'src/gui/curses')
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 26 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-key.c | 3 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 5 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-mouse.c | 5 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 6 | ||||
-rw-r--r-- | src/gui/curses/gui-curses.h | 2 |
6 files changed, 30 insertions, 17 deletions
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index e6f9b86fc..340efccb0 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -351,9 +351,11 @@ error: */ int -gui_color_timer_warning_pairs_full (void *data, int remaining_calls) +gui_color_timer_warning_pairs_full (const void *pointer, void *data, + int remaining_calls) { /* make C compiler happy */ + (void) pointer; (void) data; (void) remaining_calls; @@ -402,7 +404,7 @@ gui_color_get_pair (int fg, int bg) { /* display warning if auto reset of pairs is disabled */ hook_timer (NULL, 1, 0, 1, - &gui_color_timer_warning_pairs_full, NULL); + &gui_color_timer_warning_pairs_full, NULL, NULL); gui_color_warning_pairs_full = 1; } return 1; @@ -1034,9 +1036,10 @@ gui_color_buffer_display () */ int -gui_color_timer_cb (void *data, int remaining_calls) +gui_color_timer_cb (const void *pointer, void *data, int remaining_calls) { /* make C compiler happy */ + (void) pointer; (void) data; (void) remaining_calls; @@ -1101,7 +1104,7 @@ gui_color_switch_colors () if (gui_color_use_term_colors) { gui_color_hook_timer = hook_timer (NULL, 1000, 0, 0, - &gui_color_timer_cb, NULL); + &gui_color_timer_cb, NULL, NULL); } } @@ -1132,10 +1135,12 @@ gui_color_reset_pairs () */ int -gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer, +gui_color_buffer_input_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer, const char *input_data) { /* make C compiler happy */ + (void) pointer; (void) data; if (string_strcasecmp (input_data, "e") == 0) @@ -1164,9 +1169,11 @@ gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer, */ int -gui_color_buffer_close_cb (void *data, struct t_gui_buffer *buffer) +gui_color_buffer_close_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer) { /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; @@ -1203,9 +1210,10 @@ gui_color_buffer_open () { if (!gui_color_buffer) { - gui_color_buffer = gui_buffer_new (NULL, GUI_COLOR_BUFFER_NAME, - &gui_color_buffer_input_cb, NULL, - &gui_color_buffer_close_cb, NULL); + gui_color_buffer = gui_buffer_new ( + NULL, GUI_COLOR_BUFFER_NAME, + &gui_color_buffer_input_cb, NULL, NULL, + &gui_color_buffer_close_cb, NULL, NULL); if (gui_color_buffer) { if (!gui_color_buffer->short_name) diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c index 263ac1661..cd267064a 100644 --- a/src/gui/curses/gui-curses-key.c +++ b/src/gui/curses/gui-curses-key.c @@ -507,12 +507,13 @@ gui_key_flush (int paste) */ int -gui_key_read_cb (void *data, int fd) +gui_key_read_cb (const void *pointer, void *data, int fd) { int ret, i, accept_paste, cancel_paste, text_added_to_buffer, pos; unsigned char buffer[4096]; /* make C compiler happy */ + (void) pointer; (void) data; (void) fd; diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 210e1e4f8..cc865666b 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -181,7 +181,8 @@ gui_main_init () /* create core buffer */ ptr_buffer = gui_buffer_new (NULL, GUI_BUFFER_MAIN, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL); if (ptr_buffer) { gui_init_ok = 1; @@ -388,7 +389,7 @@ gui_main_loop () /* hook stdin (read keyboard) */ hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0, - &gui_key_read_cb, NULL); + &gui_key_read_cb, NULL, NULL); gui_window_ask_refresh (1); diff --git a/src/gui/curses/gui-curses-mouse.c b/src/gui/curses/gui-curses-mouse.c index 945837137..8620bbeee 100644 --- a/src/gui/curses/gui-curses-mouse.c +++ b/src/gui/curses/gui-curses-mouse.c @@ -218,9 +218,10 @@ gui_mouse_grab_end (const char *mouse_key) */ int -gui_mouse_event_timer_cb (void *data, int remaining_calls) +gui_mouse_event_timer_cb (const void *pointer, void *data, int remaining_calls) { /* make C compiler happy */ + (void) pointer; (void) data; (void) remaining_calls; @@ -244,7 +245,7 @@ gui_mouse_event_init () gui_mouse_event_timer = hook_timer (NULL, CONFIG_INTEGER(config_look_mouse_timer_delay), 0, 1, - &gui_mouse_event_timer_cb, NULL); + &gui_mouse_event_timer_cb, NULL, NULL); } /* diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index aa96c397c..3a8804998 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -2362,9 +2362,11 @@ gui_window_refresh_screen (int full_refresh) */ int -gui_window_bare_display_timer_cb (void *data, int remaining_calls) +gui_window_bare_display_timer_cb (const void *pointer, void *data, + int remaining_calls) { /* make C compiler happy */ + (void) pointer; (void) data; if (gui_window_bare_display) @@ -2408,7 +2410,7 @@ gui_window_bare_display_toggle (const char *delay) gui_window_bare_display_timer = hook_timer ( NULL, seconds * 1000, 0, 1, - &gui_window_bare_display_timer_cb, NULL); + &gui_window_bare_display_timer_cb, NULL, NULL); } } } diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 43d80bfbb..cbf162c27 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -98,7 +98,7 @@ extern void gui_chat_calculate_line_diff (struct t_gui_window *window, /* key functions */ extern void gui_key_default_bindings (int context); -extern int gui_key_read_cb (void *data, int fd); +extern int gui_key_read_cb (const void *pointer, void *data, int fd); /* window functions */ extern void gui_window_read_terminal_size (); |