mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 07:16:37 +02:00
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
This commit is contained in:
@@ -266,7 +266,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
trigger->hooks[i] = weechat_hook_signal (
|
||||
argv[i],
|
||||
&trigger_callback_signal_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
trigger->hooks[i] = weechat_hook_hsignal (
|
||||
argv[i],
|
||||
&trigger_callback_hsignal_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,7 +300,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
trigger->hooks[i] = weechat_hook_modifier (
|
||||
argv[i],
|
||||
&trigger_callback_modifier_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
message,
|
||||
strip_colors,
|
||||
&trigger_callback_print_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
break;
|
||||
case TRIGGER_HOOK_COMMAND:
|
||||
@@ -347,7 +347,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
(argc > 3) ? argv[3] : "", /* description of args */
|
||||
(argc > 4) ? argv[4] : "", /* completion */
|
||||
&trigger_callback_command_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -363,7 +363,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
trigger->hooks[i] = weechat_hook_command_run (
|
||||
argv[i],
|
||||
&trigger_callback_command_run_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,7 +393,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
(int)align_second,
|
||||
(int)max_calls,
|
||||
&trigger_callback_timer_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,7 +410,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
trigger->hooks[i] = weechat_hook_config (
|
||||
argv[i],
|
||||
&trigger_callback_config_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -427,7 +427,7 @@ trigger_hook (struct t_trigger *trigger)
|
||||
trigger->hooks[i] = weechat_hook_focus (
|
||||
argv[i],
|
||||
&trigger_callback_focus_cb,
|
||||
trigger);
|
||||
trigger, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1151,10 +1151,12 @@ trigger_print_log ()
|
||||
*/
|
||||
|
||||
int
|
||||
trigger_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
trigger_debug_dump_cb (const void *pointer, void *data,
|
||||
const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
@@ -1197,7 +1199,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
trigger_config_read ();
|
||||
|
||||
/* hook some signals */
|
||||
weechat_hook_signal ("debug_dump", &trigger_debug_dump_cb, NULL);
|
||||
weechat_hook_signal ("debug_dump", &trigger_debug_dump_cb, NULL, NULL);
|
||||
|
||||
/* hook completions */
|
||||
trigger_completion_init ();
|
||||
|
||||
Reference in New Issue
Block a user