mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 04:46:37 +02:00
api: return allocated string in hook_info callback and function info_get
This commit is contained in:
@@ -67,8 +67,6 @@
|
||||
plugin_script_str2ptr (weechat_lua_plugin, \
|
||||
LUA_CURRENT_SCRIPT_NAME, \
|
||||
lua_function_name, __string)
|
||||
#define API_STATIC_STRING(__string) \
|
||||
plugin_script_get_static_string(&lua_data, __string);
|
||||
#define API_RETURN_OK \
|
||||
{ \
|
||||
lua_pushinteger (L, 1); \
|
||||
@@ -3082,14 +3080,14 @@ API_FUNC(hook_modifier_exec)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
const char *
|
||||
char *
|
||||
weechat_lua_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;
|
||||
@@ -3101,12 +3099,10 @@ weechat_lua_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_lua_exec (script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
ptr_function,
|
||||
"sss", func_argv);
|
||||
|
||||
return API_STATIC_STRING(result);
|
||||
return (char *)weechat_lua_exec (script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
ptr_function,
|
||||
"sss", func_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -4343,7 +4339,8 @@ API_FUNC(command_options)
|
||||
|
||||
API_FUNC(info_get)
|
||||
{
|
||||
const char *info_name, *arguments, *result;
|
||||
const char *info_name, *arguments;
|
||||
char *result;
|
||||
|
||||
API_INIT_FUNC(1, "info_get", API_RETURN_EMPTY);
|
||||
if (lua_gettop (L) < 2)
|
||||
@@ -4354,7 +4351,7 @@ API_FUNC(info_get)
|
||||
|
||||
result = weechat_info_get (info_name, arguments);
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(info_get_hashtable)
|
||||
|
||||
Reference in New Issue
Block a user