From e5acc3977042c8ad6d8e9c60663fb052e377b5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 9 Sep 2017 15:09:34 +0200 Subject: [PATCH] php: fix arguments of hook_command callback --- src/plugins/php/weechat-php-api.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 7cfd0aefe..c79a1fef5 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -1997,35 +1997,18 @@ weechat_php_api_hook_command_cb (const void *pointer, void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { - int rc, i, *argi; - void *func_argv[4]; - struct t_hashtable *args; + int rc; + void *func_argv[3]; /* make C compiler happy */ - (void) argv_eol; - - args = weechat_hashtable_new (argc, - WEECHAT_HASHTABLE_INTEGER, - WEECHAT_HASHTABLE_STRING, - NULL, - NULL); - argi = malloc (sizeof (int) * argc); - - for (i = 0; i < argc; i++) - { - *(argi + i) = i; - weechat_hashtable_set (args, argi+i, argv[i]); - } + (void) argv; func_argv[1] = API_PTR2STR(buffer); - func_argv[2] = &argc; - func_argv[3] = args; + func_argv[2] = (argc > 1) ? argv_eol[1] : weechat_php_empty_arg; - weechat_php_cb (pointer, data, func_argv, "ssih", + weechat_php_cb (pointer, data, func_argv, "sss", WEECHAT_SCRIPT_EXEC_INT, &rc); - free (argi); - weechat_hashtable_free (args); if (func_argv[1]) free (func_argv[1]);