summaryrefslogtreecommitdiff
path: root/src/plugins/tcl
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2019-04-12 21:29:39 +0200
committerSébastien Helleu <flashcode@flashtux.org>2019-04-13 08:42:45 +0200
commit3d95217745cd269e6911a0830f7e6cc515828f07 (patch)
tree7cc372d8874c2d994c444199360c040778c3e153 /src/plugins/tcl
parentc80dc2a5ca93045ed7c358a8860532aab72f0c89 (diff)
downloadweechat-3d95217745cd269e6911a0830f7e6cc515828f07.zip
api: return allocated string in hook_info callback and function info_get
Diffstat (limited to 'src/plugins/tcl')
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c20
-rw-r--r--src/plugins/tcl/weechat-tcl.c9
2 files changed, 11 insertions, 18 deletions
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index 08b7e4f93..6609a0aea 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -68,8 +68,6 @@
plugin_script_str2ptr (weechat_tcl_plugin, \
TCL_CURRENT_SCRIPT_NAME, \
tcl_function_name, __string)
-#define API_STATIC_STRING(__string) \
- plugin_script_get_static_string(&tcl_data, __string);
#define API_RETURN_OK \
{ \
objp = Tcl_GetObjResult (interp); \
@@ -3284,14 +3282,14 @@ API_FUNC(hook_modifier_exec)
API_RETURN_STRING_FREE(result);
}
-const char *
+char *
weechat_tcl_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;
@@ -3303,12 +3301,10 @@ weechat_tcl_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_tcl_exec (script,
- WEECHAT_SCRIPT_EXEC_STRING,
- ptr_function,
- "sss", func_argv);
-
- return API_STATIC_STRING(result);
+ return (char *)weechat_tcl_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "sss", func_argv);
}
return NULL;
@@ -4631,7 +4627,7 @@ API_FUNC(command_options)
API_FUNC(info_get)
{
Tcl_Obj *objp;
- const char *result;
+ char *result;
int i;
API_INIT_FUNC(1, "info_get", API_RETURN_EMPTY);
@@ -4641,7 +4637,7 @@ API_FUNC(info_get)
result = weechat_info_get (Tcl_GetStringFromObj (objv[1], &i),
Tcl_GetStringFromObj (objv[2], &i));
- API_RETURN_STRING(result);
+ API_RETURN_STRING_FREE(result);
}
API_FUNC(info_get_hashtable)
diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c
index 9bd7c3998..cd068a74e 100644
--- a/src/plugins/tcl/weechat-tcl.c
+++ b/src/plugins/tcl/weechat-tcl.c
@@ -57,7 +57,6 @@ int tcl_eval_mode = 0;
int tcl_eval_send_input = 0;
int tcl_eval_exec_commands = 0;
struct t_gui_buffer *tcl_eval_buffer = NULL;
-char *tcl_eval_output = NULL;
struct t_plugin_script *tcl_scripts = NULL;
struct t_plugin_script *last_tcl_script = NULL;
@@ -760,12 +759,12 @@ weechat_tcl_hdata_cb (const void *pointer, void *data,
* Returns tcl info "tcl_eval".
*/
-const char *
+char *
weechat_tcl_info_eval_cb (const void *pointer, void *data,
const char *info_name,
const char *arguments)
{
- static const char *not_implemented = "not yet implemented";
+ const char *not_implemented = "not yet implemented";
/* make C compiler happy */
(void) pointer;
@@ -773,7 +772,7 @@ weechat_tcl_info_eval_cb (const void *pointer, void *data,
(void) info_name;
(void) arguments;
- return not_implemented;
+ return strdup (not_implemented);
}
/*
@@ -984,8 +983,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
if (tcl_action_autoload_list)
free (tcl_action_autoload_list);
/* weechat_string_dyn_free (tcl_buffer_output, 1); */
- if (tcl_eval_output)
- free (tcl_eval_output);
return WEECHAT_RC_OK;
}