mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 18:23:13 +02:00
api: return allocated string in hook_info callback and function info_get
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user