diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-04-12 21:29:39 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-04-13 08:42:45 +0200 |
commit | 3d95217745cd269e6911a0830f7e6cc515828f07 (patch) | |
tree | 7cc372d8874c2d994c444199360c040778c3e153 /src/plugins/ruby/weechat-ruby-api.c | |
parent | c80dc2a5ca93045ed7c358a8860532aab72f0c89 (diff) | |
download | weechat-3d95217745cd269e6911a0830f7e6cc515828f07.zip |
api: return allocated string in hook_info callback and function info_get
Diffstat (limited to 'src/plugins/ruby/weechat-ruby-api.c')
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index c5f0475d6..9d8207dee 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -57,8 +57,6 @@ plugin_script_str2ptr (weechat_ruby_plugin, \ RUBY_CURRENT_SCRIPT_NAME, \ ruby_function_name, __string) -#define API_STATIC_STRING(__string) \ - plugin_script_get_static_string(&ruby_data, __string); #define API_RETURN_OK return INT2FIX (1) #define API_RETURN_ERROR return INT2FIX (0) #define API_RETURN_EMPTY return Qnil @@ -3598,14 +3596,14 @@ weechat_ruby_api_hook_modifier_exec (VALUE class, VALUE modifier, API_RETURN_STRING_FREE(result); } -const char * +char * weechat_ruby_api_hook_info_cb (const void *pointer, void *data, const char *info_name, const char *arguments) { struct t_plugin_script *script; void *func_argv[3]; - char empty_arg[1] = { '\0' }, *result; + char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; script = (struct t_plugin_script *)pointer; @@ -3617,12 +3615,10 @@ weechat_ruby_api_hook_info_cb (const void *pointer, void *data, func_argv[1] = (info_name) ? (char *)info_name : empty_arg; func_argv[2] = (arguments) ? (char *)arguments : empty_arg; - result = (char *)weechat_ruby_exec (script, - WEECHAT_SCRIPT_EXEC_STRING, - ptr_function, - "sss", func_argv); - - return API_STATIC_STRING(result); + return (char *)weechat_ruby_exec (script, + WEECHAT_SCRIPT_EXEC_STRING, + ptr_function, + "sss", func_argv); } return NULL; @@ -5156,8 +5152,8 @@ weechat_ruby_api_command_options (VALUE class, VALUE buffer, VALUE command, static VALUE weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments) { - char *c_info_name, *c_arguments; - const char *result; + char *c_info_name, *c_arguments, *result; + VALUE return_value; API_INIT_FUNC(1, "info_get", API_RETURN_EMPTY); if (NIL_P (info_name) || NIL_P (arguments)) @@ -5171,7 +5167,7 @@ weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments) result = weechat_info_get (c_info_name, c_arguments); - API_RETURN_STRING(result); + API_RETURN_STRING_FREE(result); } static VALUE |