1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00

api: return allocated string in hook_info callback and function info_get

This commit is contained in:
Sébastien Helleu
2019-04-12 21:29:39 +02:00
parent c80dc2a5ca
commit 3d95217745
54 changed files with 724 additions and 526 deletions
+4 -7
View File
@@ -67,8 +67,6 @@
plugin_script_str2ptr (weechat_php_plugin, \
PHP_CURRENT_SCRIPT_NAME, \
php_function_name, __string)
#define API_STATIC_STRING(__string) \
plugin_script_get_static_string(&php_data, __string);
#define API_RETURN_OK RETURN_LONG((long)1)
#define API_RETURN_ERROR RETURN_LONG((long)0)
#define API_RETURN_EMPTY RETURN_NULL()
@@ -2889,7 +2887,7 @@ API_FUNC(hook_modifier_exec)
API_RETURN_STRING_FREE(result);
}
static const char *
static char *
weechat_php_api_hook_info_cb (const void *pointer,
void *data,
const char *info_name,
@@ -2904,7 +2902,7 @@ weechat_php_api_hook_info_cb (const void *pointer,
weechat_php_cb (pointer, data, func_argv, "sss",
WEECHAT_SCRIPT_EXEC_STRING, &rc);
return API_STATIC_STRING(rc);
return rc;
}
API_FUNC(hook_info)
@@ -4181,8 +4179,7 @@ API_FUNC(command_options)
API_FUNC(info_get)
{
zend_string *z_info_name, *z_arguments;
char *info_name, *arguments;
const char *result;
char *info_name, *arguments, *result;
API_INIT_FUNC(1, "info_get", API_RETURN_EMPTY);
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SS", &z_info_name,
@@ -4194,7 +4191,7 @@ API_FUNC(info_get)
result = weechat_info_get ((const char *)info_name,
(const char *)arguments);
API_RETURN_STRING(result);
API_RETURN_STRING_FREE(result);
}
API_FUNC(info_get_hashtable)
+3 -6
View File
@@ -65,7 +65,6 @@ int php_eval_mode = 0;
int php_eval_send_input = 0;
int php_eval_exec_commands = 0;
struct t_gui_buffer *php_eval_buffer = NULL;
char *php_eval_output = NULL;
struct t_plugin_script *php_scripts = NULL;
struct t_plugin_script *last_php_script = NULL;
@@ -1062,12 +1061,12 @@ weechat_php_hdata_cb (const void *pointer, void *data,
* Returns PHP info "php_eval".
*/
const char *
char *
weechat_php_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;
@@ -1075,7 +1074,7 @@ weechat_php_info_eval_cb (const void *pointer, void *data,
(void) info_name;
(void) arguments;
return not_implemented;
return strdup (not_implemented);
}
/*
@@ -1351,8 +1350,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
if (php_action_autoload_list)
free (php_action_autoload_list);
/* weechat_string_dyn_free (php_buffer_output, 1); */
if (php_eval_output)
free (php_eval_output);
return WEECHAT_RC_OK;
}