summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hook/wee-hook-info.c6
-rw-r--r--src/core/hook/wee-hook-info.h12
-rw-r--r--src/core/wee-eval.c6
3 files changed, 13 insertions, 11 deletions
diff --git a/src/core/hook/wee-hook-info.c b/src/core/hook/wee-hook-info.c
index 36d866c60..33aeb5694 100644
--- a/src/core/hook/wee-hook-info.c
+++ b/src/core/hook/wee-hook-info.c
@@ -83,14 +83,16 @@ hook_info (struct t_weechat_plugin *plugin, const char *info_name,
/*
* Gets info (as string) via info hook.
+ *
+ * Note: result must be freed after use.
*/
-const char *
+char *
hook_info_get (struct t_weechat_plugin *plugin, const char *info_name,
const char *arguments)
{
struct t_hook *ptr_hook, *next_hook;
- const char *value;
+ char *value;
/* make C compiler happy */
(void) plugin;
diff --git a/src/core/hook/wee-hook-info.h b/src/core/hook/wee-hook-info.h
index ee4d621c3..b97ad7f9b 100644
--- a/src/core/hook/wee-hook-info.h
+++ b/src/core/hook/wee-hook-info.h
@@ -25,9 +25,9 @@ struct t_infolist_item;
#define HOOK_INFO(hook, var) (((struct t_hook_info *)hook->hook_data)->var)
-typedef const char *(t_hook_callback_info)(const void *pointer, void *data,
- const char *info_name,
- const char *arguments);
+typedef char *(t_hook_callback_info)(const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments);
struct t_hook_info
{
@@ -44,9 +44,9 @@ extern struct t_hook *hook_info (struct t_weechat_plugin *plugin,
t_hook_callback_info *callback,
const void *callback_pointer,
void *callback_data);
-extern const char *hook_info_get (struct t_weechat_plugin *plugin,
- const char *info_name,
- const char *arguments);
+extern char *hook_info_get (struct t_weechat_plugin *plugin,
+ const char *info_name,
+ const char *arguments);
extern void hook_info_free_data (struct t_hook *hook);
extern int hook_info_add_to_infolist (struct t_infolist_item *item,
struct t_hook *hook);
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index 2613fc501..ab4ed94da 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -520,7 +520,7 @@ eval_replace_vars_cb (void *data, const char *text)
/* 10. info */
if (strncmp (text, "info:", 5) == 0)
{
- ptr_value = NULL;
+ value = NULL;
ptr_arguments = strchr (text + 5, ',');
if (ptr_arguments)
{
@@ -531,10 +531,10 @@ eval_replace_vars_cb (void *data, const char *text)
info_name = strdup (text + 5);
if (info_name)
{
- ptr_value = hook_info_get (NULL, info_name, ptr_arguments);
+ value = hook_info_get (NULL, info_name, ptr_arguments);
free (info_name);
}
- return strdup ((ptr_value) ? ptr_value : "");
+ return (value) ? value : strdup ("");
}
/* 11. current date/time */