diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 377 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js-api.cpp | 377 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 377 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 424 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.c | 1692 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.c | 4 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.h | 2 | ||||
-rw-r--r-- | src/plugins/plugin-script.c | 16 | ||||
-rw-r--r-- | src/plugins/plugin-script.h | 2 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 496 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 497 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 422 |
12 files changed, 2150 insertions, 2536 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 11fbc775e..a0a7450b9 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -578,20 +578,20 @@ weechat_guile_api_mkdir_parents (SCM directory, SCM mode) SCM weechat_guile_api_list_new () { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "list_new", API_RETURN_EMPTY); result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_list_add (SCM weelist, SCM data, SCM where, SCM user_data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "list_add", API_RETURN_EMPTY); @@ -604,13 +604,13 @@ weechat_guile_api_list_add (SCM weelist, SCM data, SCM where, SCM user_data) API_SCM_TO_STRING(where), API_STR2PTR(API_SCM_TO_STRING(user_data)))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_list_search (SCM weelist, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "list_search", API_RETURN_EMPTY); @@ -620,7 +620,7 @@ weechat_guile_api_list_search (SCM weelist, SCM data) result = API_PTR2STR(weechat_list_search (API_STR2PTR(API_SCM_TO_STRING(weelist)), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -641,7 +641,7 @@ weechat_guile_api_list_search_pos (SCM weelist, SCM data) SCM weechat_guile_api_list_casesearch (SCM weelist, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "list_casesearch", API_RETURN_EMPTY); @@ -651,7 +651,7 @@ weechat_guile_api_list_casesearch (SCM weelist, SCM data) result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(API_SCM_TO_STRING(weelist)), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -672,7 +672,7 @@ weechat_guile_api_list_casesearch_pos (SCM weelist, SCM data) SCM weechat_guile_api_list_get (SCM weelist, SCM position) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "list_get", API_RETURN_EMPTY); @@ -682,7 +682,7 @@ weechat_guile_api_list_get (SCM weelist, SCM position) result = API_PTR2STR(weechat_list_get (API_STR2PTR(API_SCM_TO_STRING(weelist)), scm_to_int (position))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -701,7 +701,7 @@ weechat_guile_api_list_set (SCM item, SCM new_value) SCM weechat_guile_api_list_next (SCM item) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "list_next", API_RETURN_EMPTY); @@ -710,13 +710,13 @@ weechat_guile_api_list_next (SCM item) result = API_PTR2STR(weechat_list_next (API_STR2PTR(API_SCM_TO_STRING(item)))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_list_prev (SCM item) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "list_prev", API_RETURN_EMPTY); @@ -725,7 +725,7 @@ weechat_guile_api_list_prev (SCM item) result = API_PTR2STR(weechat_list_prev (API_STR2PTR(API_SCM_TO_STRING(item)))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -810,7 +810,7 @@ weechat_guile_api_config_reload_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); rc = (int *) weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -824,8 +824,6 @@ weechat_guile_api_config_reload_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -836,7 +834,7 @@ weechat_guile_api_config_reload_cb (const void *pointer, void *data, SCM weechat_guile_api_config_new (SCM name, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "config_new", API_RETURN_EMPTY); @@ -851,7 +849,7 @@ weechat_guile_api_config_new (SCM name, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -872,8 +870,8 @@ weechat_guile_api_config_read_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -889,10 +887,6 @@ weechat_guile_api_config_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -917,7 +911,7 @@ weechat_guile_api_config_section_write_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_guile_exec (script, @@ -932,8 +926,6 @@ weechat_guile_api_config_section_write_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -958,7 +950,7 @@ weechat_guile_api_config_section_write_default_cb (const void *pointer, void *da if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_guile_exec (script, @@ -973,8 +965,6 @@ weechat_guile_api_config_section_write_default_cb (const void *pointer, void *da ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1001,8 +991,8 @@ weechat_guile_api_config_section_create_option_cb (const void *pointer, void *da if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1018,10 +1008,6 @@ weechat_guile_api_config_section_create_option_cb (const void *pointer, void *da ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1047,9 +1033,9 @@ weechat_guile_api_config_section_delete_option_cb (const void *pointer, void *da if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); rc = (int *) weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1063,12 +1049,6 @@ weechat_guile_api_config_section_delete_option_cb (const void *pointer, void *da ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1083,7 +1063,7 @@ weechat_guile_api_config_new_section (SCM args) SCM function_read, data_read, function_write, data_write; SCM function_write_default, data_write_default, function_create_option; SCM data_create_option, function_delete_option, data_delete_option; - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "config_new_section", API_RETURN_EMPTY); @@ -1138,13 +1118,13 @@ weechat_guile_api_config_new_section (SCM args) API_SCM_TO_STRING(function_delete_option), API_SCM_TO_STRING(data_delete_option))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_config_search_section (SCM config_file, SCM section_name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "config_search_section", API_RETURN_EMPTY); @@ -1154,7 +1134,7 @@ weechat_guile_api_config_search_section (SCM config_file, SCM section_name) result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(API_SCM_TO_STRING(config_file)), API_SCM_TO_STRING(section_name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1174,7 +1154,7 @@ weechat_guile_api_config_option_check_value_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_guile_exec (script, @@ -1189,8 +1169,6 @@ weechat_guile_api_config_option_check_value_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1214,16 +1192,13 @@ weechat_guile_api_config_option_change_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1245,16 +1220,13 @@ weechat_guile_api_config_option_delete_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1267,7 +1239,7 @@ weechat_guile_api_config_new_option (SCM args) SCM max, default_value, value, null_value_allowed, function_check_value; SCM data_check_value, function_change, data_change, function_delete; SCM data_delete; - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "config_new_option", API_RETURN_EMPTY); @@ -1327,14 +1299,14 @@ weechat_guile_api_config_new_option (SCM args) API_SCM_TO_STRING(function_delete), API_SCM_TO_STRING(data_delete))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_config_search_option (SCM config_file, SCM section, SCM option_name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "config_search_option", API_RETURN_EMPTY); @@ -1346,7 +1318,7 @@ weechat_guile_api_config_search_option (SCM config_file, SCM section, API_STR2PTR(API_SCM_TO_STRING(section)), API_SCM_TO_STRING(option_name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -1705,7 +1677,7 @@ weechat_guile_api_config_free (SCM config_file) SCM weechat_guile_api_config_get (SCM option) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "config_get", API_RETURN_EMPTY); @@ -1714,7 +1686,7 @@ weechat_guile_api_config_get (SCM option) result = API_PTR2STR(weechat_config_get (API_SCM_TO_STRING(option))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -1950,7 +1922,7 @@ weechat_guile_api_hook_command_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_guile_exec (script, @@ -1965,8 +1937,6 @@ weechat_guile_api_hook_command_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1979,7 +1949,7 @@ weechat_guile_api_hook_command (SCM command, SCM description, SCM args, SCM args_description, SCM completion, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_command", API_RETURN_EMPTY); @@ -2000,7 +1970,7 @@ weechat_guile_api_hook_command (SCM command, SCM description, SCM args, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2022,8 +1992,8 @@ weechat_guile_api_hook_completion_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); rc = (int *) weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -2037,10 +2007,6 @@ weechat_guile_api_hook_completion_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -2052,7 +2018,7 @@ SCM weechat_guile_api_hook_completion (SCM completion, SCM description, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY); @@ -2068,7 +2034,7 @@ weechat_guile_api_hook_completion (SCM completion, SCM description, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -2122,7 +2088,7 @@ weechat_guile_api_hook_command_run_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_guile_exec (script, @@ -2137,8 +2103,6 @@ weechat_guile_api_hook_command_run_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2149,7 +2113,7 @@ weechat_guile_api_hook_command_run_cb (const void *pointer, void *data, SCM weechat_guile_api_hook_command_run (SCM command, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_command_run", API_RETURN_EMPTY); @@ -2164,7 +2128,7 @@ weechat_guile_api_hook_command_run (SCM command, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2211,7 +2175,7 @@ SCM weechat_guile_api_hook_timer (SCM interval, SCM align_second, SCM max_calls, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); @@ -2229,7 +2193,7 @@ weechat_guile_api_hook_timer (SCM interval, SCM align_second, SCM max_calls, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2272,7 +2236,7 @@ SCM weechat_guile_api_hook_fd (SCM fd, SCM read, SCM write, SCM exception, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_fd", API_RETURN_EMPTY); @@ -2291,7 +2255,7 @@ weechat_guile_api_hook_fd (SCM fd, SCM read, SCM write, SCM exception, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2358,7 +2322,7 @@ SCM weechat_guile_api_hook_process (SCM command, SCM timeout, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_process", API_RETURN_EMPTY); @@ -2374,14 +2338,14 @@ weechat_guile_api_hook_process (SCM command, SCM timeout, SCM function, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_hook_process_hashtable (SCM command, SCM options, SCM timeout, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; struct t_hashtable *c_options; @@ -2408,7 +2372,7 @@ weechat_guile_api_hook_process_hashtable (SCM command, SCM options, SCM timeout, if (c_options) weechat_hashtable_free (c_options); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2459,7 +2423,7 @@ weechat_guile_api_hook_connect (SCM proxy, SCM address, SCM port, SCM ipv6, SCM retry, SCM local_hostname, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_connect", API_RETURN_EMPTY); @@ -2485,7 +2449,7 @@ weechat_guile_api_hook_connect (SCM proxy, SCM address, SCM port, SCM ipv6, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2514,7 +2478,7 @@ weechat_guile_api_hook_print_cb (const void *pointer, void *data, snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2536,8 +2500,6 @@ weechat_guile_api_hook_print_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); if (func_argv[3]) free (func_argv[3]); @@ -2551,7 +2513,7 @@ SCM weechat_guile_api_hook_print (SCM buffer, SCM tags, SCM message, SCM strip_colors, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_print", API_RETURN_EMPTY); @@ -2570,7 +2532,7 @@ weechat_guile_api_hook_print (SCM buffer, SCM tags, SCM message, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2583,7 +2545,7 @@ weechat_guile_api_hook_signal_cb (const void *pointer, void *data, char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; static char str_value[64]; - int *rc, ret, free_needed; + int *rc, ret; script = (struct t_plugin_script *)pointer; plugin_script_get_function_and_data (data, &ptr_function, &ptr_data); @@ -2592,7 +2554,6 @@ weechat_guile_api_hook_signal_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (signal) ? (char *)signal : empty_arg; - free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; @@ -2609,8 +2570,7 @@ weechat_guile_api_hook_signal_cb (const void *pointer, void *data, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = API_PTR2STR(signal_data); - free_needed = 1; + func_argv[2] = (char *)API_PTR2STR(signal_data); } else func_argv[2] = empty_arg; @@ -2627,8 +2587,6 @@ weechat_guile_api_hook_signal_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (free_needed && func_argv[2]) - free (func_argv[2]); return ret; } @@ -2639,7 +2597,7 @@ weechat_guile_api_hook_signal_cb (const void *pointer, void *data, SCM weechat_guile_api_hook_signal (SCM signal, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_signal", API_RETURN_EMPTY); @@ -2653,7 +2611,7 @@ weechat_guile_api_hook_signal (SCM signal, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -2740,7 +2698,7 @@ weechat_guile_api_hook_hsignal_cb (const void *pointer, void *data, SCM weechat_guile_api_hook_hsignal (SCM signal, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_hsignal", API_RETURN_EMPTY); @@ -2755,7 +2713,7 @@ weechat_guile_api_hook_hsignal (SCM signal, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -2822,7 +2780,7 @@ weechat_guile_api_hook_config_cb (const void *pointer, void *data, SCM weechat_guile_api_hook_config (SCM option, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_config", API_RETURN_EMPTY); @@ -2837,7 +2795,7 @@ weechat_guile_api_hook_config (SCM option, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -2873,7 +2831,7 @@ weechat_guile_api_hook_modifier_cb (const void *pointer, void *data, SCM weechat_guile_api_hook_modifier (SCM modifier, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_modifier", API_RETURN_EMPTY); @@ -2888,7 +2846,7 @@ weechat_guile_api_hook_modifier (SCM modifier, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -2942,7 +2900,7 @@ SCM weechat_guile_api_hook_info (SCM info_name, SCM description, SCM args_description, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_info", API_RETURN_EMPTY); @@ -2960,7 +2918,7 @@ weechat_guile_api_hook_info (SCM info_name, SCM description, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -2998,7 +2956,7 @@ weechat_guile_api_hook_info_hashtable (SCM info_name, SCM description, SCM output_description, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY); @@ -3017,7 +2975,7 @@ weechat_guile_api_hook_info_hashtable (SCM info_name, SCM description, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_infolist * @@ -3038,7 +2996,7 @@ weechat_guile_api_hook_infolist_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_guile_exec ( @@ -3047,9 +3005,6 @@ weechat_guile_api_hook_infolist_cb (const void *pointer, void *data, ptr_function, "ssss", func_argv); - if (func_argv[2]) - free (func_argv[2]); - return result; } @@ -3061,7 +3016,7 @@ weechat_guile_api_hook_infolist (SCM infolist_name, SCM description, SCM pointer_description, SCM args_description, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_infolist", API_RETURN_EMPTY); @@ -3080,7 +3035,7 @@ weechat_guile_api_hook_infolist (SCM infolist_name, SCM description, API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3113,7 +3068,7 @@ weechat_guile_api_hook_focus_cb (const void *pointer, void *data, SCM weechat_guile_api_hook_focus (SCM area, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hook_focus", API_RETURN_EMPTY); @@ -3128,7 +3083,7 @@ weechat_guile_api_hook_focus (SCM area, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3185,7 +3140,7 @@ weechat_guile_api_buffer_input_data_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_guile_exec (script, @@ -3200,8 +3155,6 @@ weechat_guile_api_buffer_input_data_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3225,7 +3178,7 @@ weechat_guile_api_buffer_close_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); rc = (int *) weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -3239,8 +3192,6 @@ weechat_guile_api_buffer_close_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3252,7 +3203,7 @@ SCM weechat_guile_api_buffer_new (SCM name, SCM function_input, SCM data_input, SCM function_close, SCM data_close) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "buffer_new", API_RETURN_EMPTY); @@ -3271,13 +3222,13 @@ weechat_guile_api_buffer_new (SCM name, SCM function_input, SCM data_input, API_SCM_TO_STRING(function_close), API_SCM_TO_STRING(data_close))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_buffer_search (SCM plugin, SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "buffer_search", API_RETURN_EMPTY); @@ -3287,33 +3238,33 @@ weechat_guile_api_buffer_search (SCM plugin, SCM name) result = API_PTR2STR(weechat_buffer_search (API_SCM_TO_STRING(plugin), API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_buffer_search_main () { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_current_buffer () { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "current_buffer", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3400,7 +3351,7 @@ weechat_guile_api_buffer_get_string (SCM buffer, SCM property) SCM weechat_guile_api_buffer_get_pointer (SCM buffer, SCM property) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY); @@ -3410,7 +3361,7 @@ weechat_guile_api_buffer_get_pointer (SCM buffer, SCM property) result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(API_SCM_TO_STRING(buffer)), API_SCM_TO_STRING(property))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3462,20 +3413,20 @@ weechat_guile_api_buffer_match_list (SCM buffer, SCM string) SCM weechat_guile_api_current_window () { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "current_window", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_window_search_with_buffer (SCM buffer) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY); @@ -3484,7 +3435,7 @@ weechat_guile_api_window_search_with_buffer (SCM buffer) result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(API_SCM_TO_STRING(buffer)))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3521,7 +3472,7 @@ weechat_guile_api_window_get_string (SCM window, SCM property) SCM weechat_guile_api_window_get_pointer (SCM window, SCM property) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "window_get_pointer", API_RETURN_EMPTY); @@ -3531,7 +3482,7 @@ weechat_guile_api_window_get_pointer (SCM window, SCM property) result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(API_SCM_TO_STRING(window)), API_SCM_TO_STRING(property))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3550,7 +3501,7 @@ SCM weechat_guile_api_nicklist_add_group (SCM buffer, SCM parent_group, SCM name, SCM color, SCM visible) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY); @@ -3565,13 +3516,13 @@ weechat_guile_api_nicklist_add_group (SCM buffer, SCM parent_group, SCM name, API_SCM_TO_STRING(color), scm_to_int (visible))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_nicklist_search_group (SCM buffer, SCM from_group, SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY); @@ -3583,7 +3534,7 @@ weechat_guile_api_nicklist_search_group (SCM buffer, SCM from_group, SCM name) API_STR2PTR(API_SCM_TO_STRING(from_group)), API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3591,7 +3542,7 @@ weechat_guile_api_nicklist_add_nick (SCM buffer, SCM group, SCM name, SCM color, SCM prefix, SCM prefix_color, SCM visible) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY); @@ -3609,13 +3560,13 @@ weechat_guile_api_nicklist_add_nick (SCM buffer, SCM group, SCM name, API_SCM_TO_STRING(prefix_color), scm_to_int (visible))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_nicklist_search_nick (SCM buffer, SCM from_group, SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY); @@ -3627,7 +3578,7 @@ weechat_guile_api_nicklist_search_nick (SCM buffer, SCM from_group, SCM name) API_STR2PTR(API_SCM_TO_STRING(from_group)), API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3709,7 +3660,7 @@ SCM weechat_guile_api_nicklist_group_get_pointer (SCM buffer, SCM group, SCM property) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY); @@ -3721,7 +3672,7 @@ weechat_guile_api_nicklist_group_get_pointer (SCM buffer, SCM group, API_STR2PTR(API_SCM_TO_STRING(group)), API_SCM_TO_STRING(property))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3778,7 +3729,7 @@ weechat_guile_api_nicklist_nick_get_string (SCM buffer, SCM nick, SCM property) SCM weechat_guile_api_nicklist_nick_get_pointer (SCM buffer, SCM nick, SCM property) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY); @@ -3790,7 +3741,7 @@ weechat_guile_api_nicklist_nick_get_pointer (SCM buffer, SCM nick, SCM property) API_STR2PTR(API_SCM_TO_STRING(nick)), API_SCM_TO_STRING(property))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3813,7 +3764,7 @@ weechat_guile_api_nicklist_nick_set (SCM buffer, SCM nick, SCM property, SCM weechat_guile_api_bar_item_search (SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "bar_item_search", API_RETURN_EMPTY); @@ -3822,7 +3773,7 @@ weechat_guile_api_bar_item_search (SCM name) result = API_PTR2STR(weechat_bar_item_search (API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -3846,39 +3797,27 @@ weechat_guile_api_bar_item_build_cb (const void *pointer, void *data, { /* new callback: data, item, window, buffer, extra_info */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = extra_info; ret = (char *)weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function + 7, "ssssh", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); } else { /* old callback: data, item, window */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); ret = (char *)weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function, "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); } return ret; @@ -3890,7 +3829,7 @@ weechat_guile_api_bar_item_build_cb (const void *pointer, void *data, SCM weechat_guile_api_bar_item_new (SCM name, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "bar_item_new", API_RETURN_EMPTY); @@ -3905,7 +3844,7 @@ weechat_guile_api_bar_item_new (SCM name, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3935,7 +3874,7 @@ weechat_guile_api_bar_item_remove (SCM item) SCM weechat_guile_api_bar_search (SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "bar_search", API_RETURN_EMPTY); @@ -3944,7 +3883,7 @@ weechat_guile_api_bar_search (SCM name) result = API_PTR2STR(weechat_bar_search (API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -3953,7 +3892,7 @@ weechat_guile_api_bar_new (SCM args) SCM name, hidden, priority, type, conditions, position, filling_top_bottom; SCM filling_left_right, size, size_max, color_fg, color_delim, color_bg; SCM separator, items; - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "bar_new", API_RETURN_EMPTY); @@ -4002,7 +3941,7 @@ weechat_guile_api_bar_new (SCM args) API_SCM_TO_STRING(separator), API_SCM_TO_STRING(items))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -4109,20 +4048,20 @@ weechat_guile_api_info_get_hashtable (SCM info_name, SCM hash) SCM weechat_guile_api_infolist_new () { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_new", API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_infolist_new_item (SCM infolist) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_new_item", API_RETURN_EMPTY); @@ -4131,13 +4070,13 @@ weechat_guile_api_infolist_new_item (SCM infolist) result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(API_SCM_TO_STRING(infolist)))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_infolist_new_var_integer (SCM item, SCM name, SCM value) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY); @@ -4149,13 +4088,13 @@ weechat_guile_api_infolist_new_var_integer (SCM item, SCM name, SCM value) API_SCM_TO_STRING(name), scm_to_int (value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_infolist_new_var_string (SCM item, SCM name, SCM value) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY); @@ -4167,13 +4106,13 @@ weechat_guile_api_infolist_new_var_string (SCM item, SCM name, SCM value) API_SCM_TO_STRING(name), API_SCM_TO_STRING(value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_infolist_new_var_pointer (SCM item, SCM name, SCM value) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY); @@ -4185,13 +4124,13 @@ weechat_guile_api_infolist_new_var_pointer (SCM item, SCM name, SCM value) API_SCM_TO_STRING(name), API_STR2PTR(API_SCM_TO_STRING(value)))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_infolist_new_var_time (SCM item, SCM name, SCM value) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); @@ -4203,13 +4142,13 @@ weechat_guile_api_infolist_new_var_time (SCM item, SCM name, SCM value) API_SCM_TO_STRING(name), scm_to_int (value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_infolist_search_var (SCM infolist, SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_search_var", API_RETURN_EMPTY); @@ -4219,13 +4158,13 @@ weechat_guile_api_infolist_search_var (SCM infolist, SCM name) result = API_PTR2STR(weechat_infolist_search_var (API_STR2PTR(API_SCM_TO_STRING(infolist)), API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_infolist_get (SCM name, SCM pointer, SCM arguments) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_get", API_RETURN_EMPTY); @@ -4237,7 +4176,7 @@ weechat_guile_api_infolist_get (SCM name, SCM pointer, SCM arguments) API_STR2PTR(API_SCM_TO_STRING(pointer)), API_SCM_TO_STRING(arguments))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -4329,7 +4268,7 @@ weechat_guile_api_infolist_string (SCM infolist, SCM variable) SCM weechat_guile_api_infolist_pointer (SCM infolist, SCM variable) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "infolist_pointer", API_RETURN_EMPTY); @@ -4339,7 +4278,7 @@ weechat_guile_api_infolist_pointer (SCM infolist, SCM variable) result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(API_SCM_TO_STRING(infolist)), API_SCM_TO_STRING(variable))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -4383,7 +4322,7 @@ weechat_guile_api_infolist_free (SCM infolist) SCM weechat_guile_api_hdata_get (SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hdata_get", API_RETURN_EMPTY); @@ -4392,7 +4331,7 @@ weechat_guile_api_hdata_get (SCM name) result = API_PTR2STR(weechat_hdata_get (API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -4481,7 +4420,7 @@ weechat_guile_api_hdata_get_var_hdata (SCM hdata, SCM name) SCM weechat_guile_api_hdata_get_list (SCM hdata, SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hdata_get_list", API_RETURN_EMPTY); @@ -4491,7 +4430,7 @@ weechat_guile_api_hdata_get_list (SCM hdata, SCM name) result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(API_SCM_TO_STRING(hdata)), API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -4514,7 +4453,7 @@ weechat_guile_api_hdata_check_pointer (SCM hdata, SCM list, SCM pointer) SCM weechat_guile_api_hdata_move (SCM hdata, SCM pointer, SCM count) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hdata_move", API_RETURN_EMPTY); @@ -4526,13 +4465,13 @@ weechat_guile_api_hdata_move (SCM hdata, SCM pointer, SCM count) API_STR2PTR(API_SCM_TO_STRING(pointer)), scm_to_int (count))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM weechat_guile_api_hdata_search (SCM hdata, SCM pointer, SCM search, SCM move) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY); @@ -4545,7 +4484,7 @@ weechat_guile_api_hdata_search (SCM hdata, SCM pointer, SCM search, SCM move) API_SCM_TO_STRING(search), scm_to_int (move))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -4620,7 +4559,7 @@ weechat_guile_api_hdata_string (SCM hdata, SCM pointer, SCM name) SCM weechat_guile_api_hdata_pointer (SCM hdata, SCM pointer, SCM name) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "hdata_pointer", API_RETURN_EMPTY); @@ -4632,7 +4571,7 @@ weechat_guile_api_hdata_pointer (SCM hdata, SCM pointer, SCM name) API_STR2PTR(API_SCM_TO_STRING(pointer)), API_SCM_TO_STRING(name))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM @@ -4751,9 +4690,9 @@ weechat_guile_api_upgrade_read_cb (const void *pointer, void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); rc = (int *) weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -4767,10 +4706,6 @@ weechat_guile_api_upgrade_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -4781,7 +4716,7 @@ weechat_guile_api_upgrade_read_cb (const void *pointer, void *data, SCM weechat_guile_api_upgrade_new (SCM filename, SCM function, SCM data) { - char *result; + const char *result; SCM return_value; API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY); @@ -4798,7 +4733,7 @@ weechat_guile_api_upgrade_new (SCM filename, SCM function, SCM data) API_SCM_TO_STRING(function), API_SCM_TO_STRING(data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } SCM diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 67c09d016..f51debb67 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -520,18 +520,18 @@ API_FUNC(mkdir_parents) API_FUNC(list_new) { - char *result; + const char *result; API_INIT_FUNC(1, "list_new", "", API_RETURN_EMPTY); result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_add) { - char *result; + const char *result; API_INIT_FUNC(1, "list_add", "ssss", API_RETURN_EMPTY); @@ -546,12 +546,12 @@ API_FUNC(list_add) *where, API_STR2PTR(*user_data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search) { - char *result; + const char *result; API_INIT_FUNC(1, "list_search", "ss", API_RETURN_EMPTY); @@ -562,7 +562,7 @@ API_FUNC(list_search) weechat_list_search ( (struct t_weelist *)API_STR2PTR(*weelist), *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search_pos) @@ -582,7 +582,7 @@ API_FUNC(list_search_pos) API_FUNC(list_casesearch) { - char *result; + const char *result; API_INIT_FUNC(1, "list_casesearch", "ss", API_RETURN_EMPTY); @@ -593,7 +593,7 @@ API_FUNC(list_casesearch) weechat_list_casesearch ( (struct t_weelist *)API_STR2PTR(*weelist), *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_casesearch_pos) @@ -614,7 +614,7 @@ API_FUNC(list_casesearch_pos) API_FUNC(list_get) { int position; - char *result; + const char *result; API_INIT_FUNC(1, "list_get", "si", API_RETURN_EMPTY); @@ -625,7 +625,7 @@ API_FUNC(list_get) weechat_list_get ((struct t_weelist *)API_STR2PTR(*weelist), position)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_set) @@ -642,7 +642,7 @@ API_FUNC(list_set) API_FUNC(list_next) { - char *result; + const char *result; API_INIT_FUNC(1, "list_next", "s", API_RETURN_EMPTY); @@ -651,12 +651,12 @@ API_FUNC(list_next) result = API_PTR2STR( weechat_list_next ((struct t_weelist_item *)API_STR2PTR(*item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_prev) { - char *result; + const char *result; API_INIT_FUNC(1, "list_prev", "s", API_RETURN_EMPTY); @@ -665,7 +665,7 @@ API_FUNC(list_prev) result = API_PTR2STR( weechat_list_prev ((struct t_weelist_item *)API_STR2PTR(*item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_string) @@ -748,7 +748,7 @@ weechat_js_api_config_reload_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -762,8 +762,6 @@ weechat_js_api_config_reload_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -773,7 +771,7 @@ weechat_js_api_config_reload_cb (const void *pointer, void *data, API_FUNC(config_new) { - char *result; + const char *result; API_INIT_FUNC(1, "config_new", "sss", API_RETURN_EMPTY); @@ -789,7 +787,7 @@ API_FUNC(config_new) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -810,8 +808,8 @@ weechat_js_api_config_read_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -827,10 +825,6 @@ weechat_js_api_config_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -855,7 +849,7 @@ weechat_js_api_config_section_write_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *)weechat_js_exec (script, @@ -870,8 +864,6 @@ weechat_js_api_config_section_write_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -896,7 +888,7 @@ weechat_js_api_config_section_write_default_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *)weechat_js_exec (script, @@ -911,8 +903,6 @@ weechat_js_api_config_section_write_default_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -939,8 +929,8 @@ weechat_js_api_config_section_create_option_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -956,10 +946,6 @@ weechat_js_api_config_section_create_option_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -985,9 +971,9 @@ weechat_js_api_config_section_delete_option_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1001,12 +987,6 @@ weechat_js_api_config_section_delete_option_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1017,7 +997,7 @@ weechat_js_api_config_section_delete_option_cb (const void *pointer, void *data, API_FUNC(config_new_section) { int user_can_add_options, user_can_delete_options; - char *result; + const char *result; API_INIT_FUNC(1, "config_new_section", "ssiissssssssss", API_RETURN_EMPTY); @@ -1060,12 +1040,12 @@ API_FUNC(config_new_section) *function_delete_option, *data_delete_option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_section) { - char *result; + const char *result; API_INIT_FUNC(1, "config_search_section", "ss", API_RETURN_EMPTY); @@ -1077,7 +1057,7 @@ API_FUNC(config_search_section) (struct t_config_file *) API_STR2PTR(*config_file), *section_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1097,7 +1077,7 @@ weechat_js_api_config_option_check_value_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *)weechat_js_exec (script, @@ -1112,8 +1092,6 @@ weechat_js_api_config_option_check_value_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1137,16 +1115,13 @@ weechat_js_api_config_option_change_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1168,16 +1143,13 @@ weechat_js_api_config_option_delete_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1186,7 +1158,7 @@ weechat_js_api_config_option_delete_cb (const void *pointer, void *data, API_FUNC(config_new_option) { int min, max, null_value_allowed; - char *result; + const char *result; API_INIT_FUNC(1, "config_new_option", "ssssssiississssss", API_RETURN_EMPTY); @@ -1233,12 +1205,12 @@ API_FUNC(config_new_option) *function_delete, *data_delete)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_option) { - char *result; + const char *result; API_INIT_FUNC(1, "config_search_option", "sss", API_RETURN_EMPTY); @@ -1252,7 +1224,7 @@ API_FUNC(config_search_option) (struct t_config_section *)API_STR2PTR(*section), *option_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_string_to_boolean) @@ -1603,7 +1575,7 @@ API_FUNC(config_free) API_FUNC(config_get) { - char *result; + const char *result; API_INIT_FUNC(1, "config_get", "s", API_RETURN_EMPTY); @@ -1611,7 +1583,7 @@ API_FUNC(config_get) result = API_PTR2STR(weechat_config_get (*option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_get_plugin) @@ -1843,7 +1815,7 @@ weechat_js_api_hook_command_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *)weechat_js_exec (script, @@ -1858,8 +1830,6 @@ weechat_js_api_hook_command_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1869,7 +1839,7 @@ weechat_js_api_hook_command_cb (const void *pointer, void *data, API_FUNC(hook_command) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_command", "sssssss", API_RETURN_EMPTY); @@ -1893,7 +1863,7 @@ API_FUNC(hook_command) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1915,8 +1885,8 @@ weechat_js_api_hook_completion_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1930,10 +1900,6 @@ weechat_js_api_hook_completion_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1943,7 +1909,7 @@ weechat_js_api_hook_completion_cb (const void *pointer, void *data, API_FUNC(hook_completion) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_completion", "ssss", API_RETURN_EMPTY); @@ -1962,7 +1928,7 @@ API_FUNC(hook_completion) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_completion_get_string) @@ -2018,7 +1984,7 @@ weechat_js_api_hook_command_run_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *)weechat_js_exec (script, @@ -2033,8 +1999,6 @@ weechat_js_api_hook_command_run_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2044,7 +2008,7 @@ weechat_js_api_hook_command_run_cb (const void *pointer, void *data, API_FUNC(hook_command_run) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_command_run", "sss", API_RETURN_EMPTY); @@ -2061,7 +2025,7 @@ API_FUNC(hook_command_run) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2107,7 +2071,7 @@ weechat_js_api_hook_timer_cb (const void *pointer, void *data, API_FUNC(hook_timer) { int interval, align_second, max_calls; - char *result; + const char *result; API_INIT_FUNC(1, "hook_timer", "iiiss", API_RETURN_EMPTY); @@ -2128,7 +2092,7 @@ API_FUNC(hook_timer) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2170,7 +2134,7 @@ weechat_js_api_hook_fd_cb (const void *pointer, void *data, int fd) API_FUNC(hook_fd) { int fd, read, write, exception; - char *result; + const char *result; API_INIT_FUNC(1, "hook_fd", "iiiiss", API_RETURN_EMPTY); @@ -2193,7 +2157,7 @@ API_FUNC(hook_fd) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2259,7 +2223,7 @@ weechat_js_api_hook_process_cb (const void *pointer, void *data, API_FUNC(hook_process) { int timeout; - char *result; + const char *result; API_INIT_FUNC(1, "hook_process", "siss", API_RETURN_EMPTY); @@ -2278,14 +2242,14 @@ API_FUNC(hook_process) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_process_hashtable) { struct t_hashtable *options; int timeout; - char *result; + const char *result; API_INIT_FUNC(1, "hook_process_hashtable", "shiss", API_RETURN_EMPTY); @@ -2313,7 +2277,7 @@ API_FUNC(hook_process_hashtable) if (options) weechat_hashtable_free (options); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2362,7 +2326,7 @@ weechat_js_api_hook_connect_cb (const void *pointer, void *data, API_FUNC(hook_connect) { int port, ipv6, retry; - char *result; + const char *result; API_INIT_FUNC(1, "hook_connect", "ssiiisss", API_RETURN_EMPTY); @@ -2393,7 +2357,7 @@ API_FUNC(hook_connect) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2422,7 +2386,7 @@ weechat_js_api_hook_print_cb (const void *pointer, void *data, snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2444,8 +2408,6 @@ weechat_js_api_hook_print_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); if (func_argv[3]) free (func_argv[3]); @@ -2458,7 +2420,7 @@ weechat_js_api_hook_print_cb (const void *pointer, void *data, API_FUNC(hook_print) { int strip_colors; - char *result; + const char *result; API_INIT_FUNC(1, "hook_print", "sssiss", API_RETURN_EMPTY); @@ -2481,7 +2443,7 @@ API_FUNC(hook_print) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2494,7 +2456,7 @@ weechat_js_api_hook_signal_cb (const void *pointer, void *data, char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; static char str_value[64]; - int *rc, ret, free_needed; + int *rc, ret; script = (struct t_plugin_script *)pointer; plugin_script_get_function_and_data (data, &ptr_function, &ptr_data); @@ -2503,7 +2465,6 @@ weechat_js_api_hook_signal_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (signal) ? (char *)signal : empty_arg; - free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; @@ -2520,8 +2481,7 @@ weechat_js_api_hook_signal_cb (const void *pointer, void *data, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = API_PTR2STR(signal_data); - free_needed = 1; + func_argv[2] = (char *)API_PTR2STR(signal_data); } else func_argv[2] = empty_arg; @@ -2538,8 +2498,6 @@ weechat_js_api_hook_signal_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (free_needed && func_argv[2]) - free (func_argv[2]); return ret; } @@ -2549,7 +2507,7 @@ weechat_js_api_hook_signal_cb (const void *pointer, void *data, API_FUNC(hook_signal) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_signal", "sss", API_RETURN_EMPTY); @@ -2566,7 +2524,7 @@ API_FUNC(hook_signal) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_signal_send) @@ -2646,7 +2604,7 @@ weechat_js_api_hook_hsignal_cb (const void *pointer, void *data, API_FUNC(hook_hsignal) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_hsignal", "sss", API_RETURN_EMPTY); @@ -2663,7 +2621,7 @@ API_FUNC(hook_hsignal) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_hsignal_send) @@ -2728,7 +2686,7 @@ weechat_js_api_hook_config_cb (const void *pointer, void *data, API_FUNC(hook_config) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_config", "sss", API_RETURN_EMPTY); @@ -2745,7 +2703,7 @@ API_FUNC(hook_config) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -2779,7 +2737,7 @@ weechat_js_api_hook_modifier_cb (const void *pointer, void *data, API_FUNC(hook_modifier) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_modifier", "sss", API_RETURN_EMPTY); @@ -2796,7 +2754,7 @@ API_FUNC(hook_modifier) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_modifier_exec) @@ -2844,7 +2802,7 @@ weechat_js_api_hook_info_cb (const void *pointer, void *data, API_FUNC(hook_info) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_info", "sssss", API_RETURN_EMPTY); @@ -2865,7 +2823,7 @@ API_FUNC(hook_info) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -2902,7 +2860,7 @@ weechat_js_api_hook_info_hashtable_cb (const void *pointer, void *data, API_FUNC(hook_info_hashtable) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_info_hashtable", "ssssss", API_RETURN_EMPTY); @@ -2925,7 +2883,7 @@ API_FUNC(hook_info_hashtable) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_infolist * @@ -2946,7 +2904,7 @@ weechat_js_api_hook_infolist_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_js_exec ( @@ -2955,9 +2913,6 @@ weechat_js_api_hook_infolist_cb (const void *pointer, void *data, ptr_function, "ssss", func_argv); - if (func_argv[2]) - free (func_argv[2]); - return result; } @@ -2966,7 +2921,7 @@ weechat_js_api_hook_infolist_cb (const void *pointer, void *data, API_FUNC(hook_infolist) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_infolist", "ssssss", API_RETURN_EMPTY); @@ -2989,7 +2944,7 @@ API_FUNC(hook_infolist) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3024,7 +2979,7 @@ weechat_js_api_hook_focus_cb (const void *pointer, void *data, API_FUNC(hook_focus) { - char *result; + const char *result; API_INIT_FUNC(1, "hook_focus", "sss", API_RETURN_EMPTY); @@ -3041,7 +2996,7 @@ API_FUNC(hook_focus) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_set) @@ -3096,7 +3051,7 @@ weechat_js_api_buffer_input_data_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *)weechat_js_exec (script, @@ -3112,9 +3067,6 @@ weechat_js_api_buffer_input_data_cb (const void *pointer, void *data, free (rc); } - if (func_argv[1]) - free (func_argv[1]); - return ret; } @@ -3137,7 +3089,7 @@ weechat_js_api_buffer_close_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -3152,9 +3104,6 @@ weechat_js_api_buffer_close_cb (const void *pointer, void *data, free (rc); } - if (func_argv[1]) - free (func_argv[1]); - return ret; } @@ -3163,7 +3112,7 @@ weechat_js_api_buffer_close_cb (const void *pointer, void *data, API_FUNC(buffer_new) { - char *result; + const char *result; API_INIT_FUNC(1, "buffer_new", "sssss", API_RETURN_EMPTY); @@ -3185,12 +3134,12 @@ API_FUNC(buffer_new) *function_close, *data_close)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search) { - char *result; + const char *result; API_INIT_FUNC(1, "buffer_search", "ss", API_RETURN_EMPTY); @@ -3199,29 +3148,29 @@ API_FUNC(buffer_search) result = API_PTR2STR(weechat_buffer_search (*plugin, *name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search_main) { - char *result; + const char *result; API_INIT_FUNC(1, "buffer_search_main", "", API_RETURN_EMPTY); result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(current_buffer) { - char *result; + const char *result; API_INIT_FUNC(1, "current_buffer", "", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_clear) @@ -3308,7 +3257,7 @@ API_FUNC(buffer_get_string) API_FUNC(buffer_get_pointer) { - char *result; + const char *result; API_INIT_FUNC(1, "buffer_get_pointer", "ss", API_RETURN_EMPTY); @@ -3320,7 +3269,7 @@ API_FUNC(buffer_get_pointer) (struct t_gui_buffer *)API_STR2PTR(*buffer), *property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_set) @@ -3373,18 +3322,18 @@ API_FUNC(buffer_match_list) API_FUNC(current_window) { - char *result; + const char *result; API_INIT_FUNC(1, "current_window", "", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_search_with_buffer) { - char *result; + const char *result; API_INIT_FUNC(1, "window_search_with_buffer", "s", API_RETURN_EMPTY); @@ -3394,7 +3343,7 @@ API_FUNC(window_search_with_buffer) weechat_window_search_with_buffer ( (struct t_gui_buffer *)API_STR2PTR(*buffer))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_get_integer) @@ -3431,7 +3380,7 @@ API_FUNC(window_get_string) API_FUNC(window_get_pointer) { - char *result; + const char *result; API_INIT_FUNC(1, "window_get_pointer", "ss", API_RETURN_EMPTY); @@ -3443,7 +3392,7 @@ API_FUNC(window_get_pointer) (struct t_gui_window *)API_STR2PTR(*window), *property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_set_title) @@ -3460,7 +3409,7 @@ API_FUNC(window_set_title) API_FUNC(nicklist_add_group) { int visible; - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_add_group", "ssssi", API_RETURN_EMPTY); @@ -3478,12 +3427,12 @@ API_FUNC(nicklist_add_group) *color, visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_group) { - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_search_group", "sss", API_RETURN_EMPTY); @@ -3497,13 +3446,13 @@ API_FUNC(nicklist_search_group) (struct t_gui_nick_group *)API_STR2PTR(*from_group), *name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_add_nick) { int visible; - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_add_nick", "ssssssi", API_RETURN_EMPTY); @@ -3525,12 +3474,12 @@ API_FUNC(nicklist_add_nick) *prefix_color, visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_nick) { - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_search_nick", "sss", API_RETURN_EMPTY); @@ -3544,7 +3493,7 @@ API_FUNC(nicklist_search_nick) (struct t_gui_nick_group *)API_STR2PTR(*from_group), *name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_remove_group) @@ -3624,7 +3573,7 @@ API_FUNC(nicklist_group_get_string) API_FUNC(nicklist_group_get_pointer) { - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_group_get_pointer", "sss", API_RETURN_EMPTY); @@ -3638,7 +3587,7 @@ API_FUNC(nicklist_group_get_pointer) (struct t_gui_nick_group *)API_STR2PTR(*group), *property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_group_set) @@ -3697,7 +3646,7 @@ API_FUNC(nicklist_nick_get_string) API_FUNC(nicklist_nick_get_pointer) { - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_nick_get_pointer", "sss", API_RETURN_EMPTY); @@ -3711,7 +3660,7 @@ API_FUNC(nicklist_nick_get_pointer) (struct t_gui_nick *)API_STR2PTR(*nick), *property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_nick_set) @@ -3734,7 +3683,7 @@ API_FUNC(nicklist_nick_set) API_FUNC(bar_item_search) { - char *result; + const char *result; API_INIT_FUNC(1, "bar_item_search", "s", API_RETURN_EMPTY); @@ -3742,7 +3691,7 @@ API_FUNC(bar_item_search) result = API_PTR2STR(weechat_bar_item_search (*name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -3766,39 +3715,27 @@ weechat_js_api_bar_item_build_cb (const void *pointer, void *data, { /* new callback: data, item, window, buffer, extra_info */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = extra_info; ret = (char *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function + 7, "ssssh", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); } else { /* old callback: data, item, window */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); ret = (char *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function, "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); } return ret; @@ -3809,7 +3746,7 @@ weechat_js_api_bar_item_build_cb (const void *pointer, void *data, API_FUNC(bar_item_new) { - char *result; + const char *result; API_INIT_FUNC(1, "bar_item_new", "sss", API_RETURN_EMPTY); @@ -3826,7 +3763,7 @@ API_FUNC(bar_item_new) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_item_update) @@ -3853,7 +3790,7 @@ API_FUNC(bar_item_remove) API_FUNC(bar_search) { - char *result; + const char *result; API_INIT_FUNC(1, "bar_search", "s", API_RETURN_EMPTY); @@ -3861,12 +3798,12 @@ API_FUNC(bar_search) result = API_PTR2STR(weechat_bar_search (*name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_new) { - char *result; + const char *result; API_INIT_FUNC(1, "bar_new", "sssssssssssssss", API_RETURN_EMPTY); @@ -3902,7 +3839,7 @@ API_FUNC(bar_new) *separator, *items)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_set) @@ -4004,18 +3941,18 @@ API_FUNC(info_get_hashtable) API_FUNC(infolist_new) { - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new", "", API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_item) { - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_item", "s", API_RETURN_EMPTY); @@ -4025,13 +3962,13 @@ API_FUNC(infolist_new_item) weechat_infolist_new_item ( (struct t_infolist *)API_STR2PTR(*infolist))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_integer) { int value; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_var_integer", "ssi", API_RETURN_EMPTY); @@ -4045,12 +3982,12 @@ API_FUNC(infolist_new_var_integer) *name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_string) { - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_var_string", "sss", API_RETURN_EMPTY); @@ -4064,12 +4001,12 @@ API_FUNC(infolist_new_var_string) *name, *value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_pointer) { - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_var_pointer", "sss", API_RETURN_EMPTY); @@ -4083,13 +4020,13 @@ API_FUNC(infolist_new_var_pointer) *name, API_STR2PTR(*value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_time) { int value; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_var_time", "ssi", API_RETURN_EMPTY); @@ -4103,12 +4040,12 @@ API_FUNC(infolist_new_var_time) *name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_search_var) { - char *result; + const char *result; API_INIT_FUNC(1, "infolist_search_var", "ss", API_RETURN_EMPTY); @@ -4120,12 +4057,12 @@ API_FUNC(infolist_search_var) (struct t_infolist *)API_STR2PTR(*infolist), *name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_get) { - char *result; + const char *result; API_INIT_FUNC(1, "infolist_get", "sss", API_RETURN_EMPTY); @@ -4139,7 +4076,7 @@ API_FUNC(infolist_get) API_STR2PTR(*pointer), *arguments)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_next) @@ -4242,7 +4179,7 @@ API_FUNC(infolist_pointer) (struct t_infolist *)API_STR2PTR(*infolist), *variable)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_time) @@ -4280,7 +4217,7 @@ API_FUNC(infolist_free) API_FUNC(hdata_get) { - char *result; + const char *result; API_INIT_FUNC(1, "hdata_get", "s", API_RETURN_EMPTY); @@ -4288,7 +4225,7 @@ API_FUNC(hdata_get) result = API_PTR2STR(weechat_hdata_get (*name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_offset) @@ -4377,7 +4314,7 @@ API_FUNC(hdata_get_var_hdata) API_FUNC(hdata_get_list) { - char *result; + const char *result; API_INIT_FUNC(1, "hdata_get_list", "s", API_RETURN_EMPTY); @@ -4389,7 +4326,7 @@ API_FUNC(hdata_get_list) (struct t_hdata *)API_STR2PTR(*hdata), *name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_check_pointer) @@ -4413,7 +4350,7 @@ API_FUNC(hdata_check_pointer) API_FUNC(hdata_move) { int count; - char *result; + const char *result; API_INIT_FUNC(1, "hdata_move", "ssi", API_RETURN_EMPTY); @@ -4427,13 +4364,13 @@ API_FUNC(hdata_move) API_STR2PTR(*pointer), count)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_search) { int move; - char *result; + const char *result; API_INIT_FUNC(1, "hdata_search", "sssi", API_RETURN_EMPTY); @@ -4449,7 +4386,7 @@ API_FUNC(hdata_search) *search, move)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_char) @@ -4526,7 +4463,7 @@ API_FUNC(hdata_string) API_FUNC(hdata_pointer) { - char *result; + const char *result; API_INIT_FUNC(1, "hdata_pointer", "sss", API_RETURN_EMPTY); @@ -4540,7 +4477,7 @@ API_FUNC(hdata_pointer) API_STR2PTR(*pointer), *name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_time) @@ -4664,9 +4601,9 @@ weechat_js_api_upgrade_read_cb (const void *pointer, void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -4680,10 +4617,6 @@ weechat_js_api_upgrade_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -4693,7 +4626,7 @@ weechat_js_api_upgrade_read_cb (const void *pointer, void *data, API_FUNC(upgrade_new) { - char *result; + const char *result; API_INIT_FUNC(1, "upgrade_new", "sss", API_RETURN_EMPTY); @@ -4710,7 +4643,7 @@ API_FUNC(upgrade_new) *function, *data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(upgrade_write_object) diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index b04c72df5..1fb82b8cd 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -562,19 +562,19 @@ API_FUNC(mkdir_parents) API_FUNC(list_new) { - char *result; + const char *result; API_INIT_FUNC(1, "list_new", API_RETURN_EMPTY); result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_add) { const char *weelist, *data, *where, *user_data; - char *result; + const char *result; API_INIT_FUNC(1, "list_add", API_RETURN_EMPTY); if (lua_gettop (L) < 4) @@ -590,13 +590,13 @@ API_FUNC(list_add) where, API_STR2PTR(user_data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search) { const char *weelist, *data; - char *result; + const char *result; API_INIT_FUNC(1, "list_search", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -608,7 +608,7 @@ API_FUNC(list_search) result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search_pos) @@ -631,7 +631,7 @@ API_FUNC(list_search_pos) API_FUNC(list_casesearch) { const char *weelist, *data; - char *result; + const char *result; API_INIT_FUNC(1, "list_casesearch", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -643,7 +643,7 @@ API_FUNC(list_casesearch) result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_casesearch_pos) @@ -666,7 +666,7 @@ API_FUNC(list_casesearch_pos) API_FUNC(list_get) { const char *weelist; - char *result; + const char *result; int position; API_INIT_FUNC(1, "list_get", API_RETURN_EMPTY); @@ -679,7 +679,7 @@ API_FUNC(list_get) result = API_PTR2STR(weechat_list_get (API_STR2PTR(weelist), position)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_set) @@ -702,7 +702,7 @@ API_FUNC(list_set) API_FUNC(list_next) { const char *item; - char *result; + const char *result; API_INIT_FUNC(1, "list_next", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -712,13 +712,13 @@ API_FUNC(list_next) result = API_PTR2STR(weechat_list_next (API_STR2PTR(item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_prev) { const char *item; - char *result; + const char *result; API_INIT_FUNC(1, "list_prev", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -728,7 +728,7 @@ API_FUNC(list_prev) result = API_PTR2STR(weechat_list_prev (API_STR2PTR(item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_string) @@ -825,7 +825,7 @@ weechat_lua_api_config_reload_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); rc = (int *) weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -839,8 +839,6 @@ weechat_lua_api_config_reload_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -851,7 +849,7 @@ weechat_lua_api_config_reload_cb (const void *pointer, void *data, API_FUNC(config_new) { const char *name, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "config_new", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -868,7 +866,7 @@ API_FUNC(config_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -889,8 +887,8 @@ weechat_lua_api_config_read_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -906,10 +904,6 @@ weechat_lua_api_config_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -934,7 +928,7 @@ weechat_lua_api_config_section_write_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_lua_exec (script, @@ -949,8 +943,6 @@ weechat_lua_api_config_section_write_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -975,7 +967,7 @@ weechat_lua_api_config_section_write_default_cb (const void *pointer, void *data if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_lua_exec (script, @@ -990,8 +982,6 @@ weechat_lua_api_config_section_write_default_cb (const void *pointer, void *data ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1018,8 +1008,8 @@ weechat_lua_api_config_section_create_option_cb (const void *pointer, void *data if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1035,10 +1025,6 @@ weechat_lua_api_config_section_create_option_cb (const void *pointer, void *data ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1064,9 +1050,9 @@ weechat_lua_api_config_section_delete_option_cb (const void *pointer, void *data if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); rc = (int *) weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1080,12 +1066,6 @@ weechat_lua_api_config_section_delete_option_cb (const void *pointer, void *data ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1100,7 +1080,7 @@ API_FUNC(config_new_section) const char *data_write_default, *function_create_option; const char *data_create_option, *function_delete_option; const char *data_delete_option; - char *result; + const char *result; int user_can_add_options, user_can_delete_options; API_INIT_FUNC(1, "config_new_section", API_RETURN_EMPTY); @@ -1146,13 +1126,13 @@ API_FUNC(config_new_section) function_delete_option, data_delete_option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_section) { const char *config_file, *section_name; - char *result; + const char *result; API_INIT_FUNC(1, "config_search_section", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -1164,7 +1144,7 @@ API_FUNC(config_search_section) result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), section_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1184,7 +1164,7 @@ weechat_lua_api_config_option_check_value_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_lua_exec (script, @@ -1199,8 +1179,6 @@ weechat_lua_api_config_option_check_value_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1224,16 +1202,13 @@ weechat_lua_api_config_option_change_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1255,16 +1230,13 @@ weechat_lua_api_config_option_delete_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1276,7 +1248,7 @@ API_FUNC(config_new_option) const char *string_values, *default_value, *value; const char *function_check_value, *data_check_value, *function_change; const char *data_change, *function_delete, *data_delete; - char *result; + const char *result; int min, max, null_value_allowed; API_INIT_FUNC(1, "config_new_option", API_RETURN_EMPTY); @@ -1324,13 +1296,13 @@ API_FUNC(config_new_option) function_delete, data_delete)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_option) { const char *config_file, *section, *option_name; - char *result; + const char *result; API_INIT_FUNC(1, "config_search_option", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -1344,7 +1316,7 @@ API_FUNC(config_search_option) API_STR2PTR(section), option_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_string_to_boolean) @@ -1756,7 +1728,7 @@ API_FUNC(config_free) API_FUNC(config_get) { const char *option; - char *result; + const char *result; API_INIT_FUNC(1, "config_get", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -1766,7 +1738,7 @@ API_FUNC(config_get) result = API_PTR2STR(weechat_config_get (option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_get_plugin) @@ -2034,7 +2006,7 @@ weechat_lua_api_hook_command_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_lua_exec (script, @@ -2049,8 +2021,6 @@ weechat_lua_api_hook_command_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2062,7 +2032,7 @@ API_FUNC(hook_command) { const char *command, *description, *args, *args_description, *completion; const char *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_command", API_RETURN_EMPTY); if (lua_gettop (L) < 7) @@ -2087,7 +2057,7 @@ API_FUNC(hook_command) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2109,8 +2079,8 @@ weechat_lua_api_hook_completion_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); rc = (int *) weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -2124,10 +2094,6 @@ weechat_lua_api_hook_completion_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -2138,7 +2104,7 @@ weechat_lua_api_hook_completion_cb (const void *pointer, void *data, API_FUNC(hook_completion) { const char *completion, *description, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY); if (lua_gettop (L) < 4) @@ -2157,7 +2123,7 @@ API_FUNC(hook_completion) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_completion_get_string) @@ -2216,7 +2182,7 @@ weechat_lua_api_hook_command_run_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_lua_exec (script, @@ -2231,8 +2197,6 @@ weechat_lua_api_hook_command_run_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2243,7 +2207,7 @@ weechat_lua_api_hook_command_run_cb (const void *pointer, void *data, API_FUNC(hook_command_run) { const char *command, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_command_run", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -2260,7 +2224,7 @@ API_FUNC(hook_command_run) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2307,7 +2271,7 @@ API_FUNC(hook_timer) { int interval, align_second, max_calls; const char *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); if (lua_gettop (L) < 5) @@ -2328,7 +2292,7 @@ API_FUNC(hook_timer) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2371,7 +2335,7 @@ API_FUNC(hook_fd) { int fd, read, write, exception; const char *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_fd", API_RETURN_EMPTY); if (lua_gettop (L) < 6) @@ -2394,7 +2358,7 @@ API_FUNC(hook_fd) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2461,7 +2425,7 @@ API_FUNC(hook_process) { const char *command, *function, *data; int timeout; - char *result; + const char *result; API_INIT_FUNC(1, "hook_process", API_RETURN_EMPTY); if (lua_gettop (L) < 4) @@ -2480,7 +2444,7 @@ API_FUNC(hook_process) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_process_hashtable) @@ -2488,7 +2452,7 @@ API_FUNC(hook_process_hashtable) const char *command, *function, *data; struct t_hashtable *options; int timeout; - char *result; + const char *result; API_INIT_FUNC(1, "hook_process_hashtable", API_RETURN_EMPTY); if (lua_gettop (L) < 5) @@ -2515,7 +2479,7 @@ API_FUNC(hook_process_hashtable) if (options) weechat_hashtable_free (options); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2565,7 +2529,7 @@ API_FUNC(hook_connect) { const char *proxy, *address, *local_hostname, *function, *data; int port, ipv6, retry; - char *result; + const char *result; API_INIT_FUNC(1, "hook_connect", API_RETURN_EMPTY); if (lua_gettop (L) < 8) @@ -2596,7 +2560,7 @@ API_FUNC(hook_connect) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2625,7 +2589,7 @@ weechat_lua_api_hook_print_cb (const void *pointer, void *data, snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2647,8 +2611,6 @@ weechat_lua_api_hook_print_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); if (func_argv[3]) free (func_argv[3]); @@ -2661,7 +2623,7 @@ weechat_lua_api_hook_print_cb (const void *pointer, void *data, API_FUNC(hook_print) { const char *buffer, *tags, *message, *function, *data; - char *result; + const char *result; int strip_colors; API_INIT_FUNC(1, "hook_print", API_RETURN_EMPTY); @@ -2685,7 +2647,7 @@ API_FUNC(hook_print) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2698,7 +2660,7 @@ weechat_lua_api_hook_signal_cb (const void *pointer, void *data, char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; static char str_value[64]; - int *rc, ret, free_needed; + int *rc, ret; script = (struct t_plugin_script *)pointer; plugin_script_get_function_and_data (data, &ptr_function, &ptr_data); @@ -2707,7 +2669,6 @@ weechat_lua_api_hook_signal_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (signal) ? (char *)signal : empty_arg; - free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; @@ -2724,8 +2685,7 @@ weechat_lua_api_hook_signal_cb (const void *pointer, void *data, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = API_PTR2STR(signal_data); - free_needed = 1; + func_argv[2] = (char *)API_PTR2STR(signal_data); } else func_argv[2] = empty_arg; @@ -2742,8 +2702,6 @@ weechat_lua_api_hook_signal_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (free_needed && func_argv[2]) - free (func_argv[2]); return ret; } @@ -2754,7 +2712,7 @@ weechat_lua_api_hook_signal_cb (const void *pointer, void *data, API_FUNC(hook_signal) { const char *signal, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_signal", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -2771,7 +2729,7 @@ API_FUNC(hook_signal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_signal_send) @@ -2853,7 +2811,7 @@ weechat_lua_api_hook_hsignal_cb (const void *pointer, void *data, API_FUNC(hook_hsignal) { const char *signal, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_hsignal", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -2870,7 +2828,7 @@ API_FUNC(hook_hsignal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_hsignal_send) @@ -2938,7 +2896,7 @@ weechat_lua_api_hook_config_cb (const void *pointer, void *data, API_FUNC(hook_config) { const char *option, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_config", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -2955,7 +2913,7 @@ API_FUNC(hook_config) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -2991,7 +2949,7 @@ weechat_lua_api_hook_modifier_cb (const void *pointer, void *data, API_FUNC(hook_modifier) { const char *modifier, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_modifier", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -3008,7 +2966,7 @@ API_FUNC(hook_modifier) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_modifier_exec) @@ -3060,7 +3018,7 @@ weechat_lua_api_hook_info_cb (const void *pointer, void *data, API_FUNC(hook_info) { const char *info_name, *description, *args_description, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_info", API_RETURN_EMPTY); if (lua_gettop (L) < 5) @@ -3081,7 +3039,7 @@ API_FUNC(hook_info) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3117,7 +3075,7 @@ API_FUNC(hook_info_hashtable) { const char *info_name, *description, *args_description; const char *output_description, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY); if (lua_gettop (L) < 6) @@ -3140,7 +3098,7 @@ API_FUNC(hook_info_hashtable) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_infolist * @@ -3161,7 +3119,7 @@ weechat_lua_api_hook_infolist_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (info_name) ? (char *)info_name : empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_lua_exec ( @@ -3170,9 +3128,6 @@ weechat_lua_api_hook_infolist_cb (const void *pointer, void *data, ptr_function, "ssss", func_argv); - if (func_argv[2]) - free (func_argv[2]); - return result; } @@ -3183,7 +3138,7 @@ API_FUNC(hook_infolist) { const char *infolist_name, *description, *pointer_description; const char *args_description, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_infolist", API_RETURN_EMPTY); if (lua_gettop (L) < 6) @@ -3206,7 +3161,7 @@ API_FUNC(hook_infolist) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3239,7 +3194,7 @@ weechat_lua_api_hook_focus_cb (const void *pointer, void *data, API_FUNC(hook_focus) { const char *area, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "hook_focus", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -3256,7 +3211,7 @@ API_FUNC(hook_focus) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_set) @@ -3317,7 +3272,7 @@ weechat_lua_api_buffer_input_data_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_lua_exec (script, @@ -3332,8 +3287,6 @@ weechat_lua_api_buffer_input_data_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3357,7 +3310,7 @@ weechat_lua_api_buffer_close_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); rc = (int *) weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -3371,8 +3324,6 @@ weechat_lua_api_buffer_close_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3384,7 +3335,7 @@ API_FUNC(buffer_new) { const char *name, *function_input, *data_input, *function_close; const char *data_close; - char *result; + const char *result; API_INIT_FUNC(1, "buffer_new", API_RETURN_EMPTY); if (lua_gettop (L) < 5) @@ -3406,13 +3357,13 @@ API_FUNC(buffer_new) function_close, data_close)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search) { const char *plugin, *name; - char *result; + const char *result; API_INIT_FUNC(1, "buffer_search", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -3423,29 +3374,29 @@ API_FUNC(buffer_search) result = API_PTR2STR(weechat_buffer_search (plugin, name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search_main) { - char *result; + const char *result; API_INIT_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(current_buffer) { - char *result; + const char *result; API_INIT_FUNC(1, "current_buffer", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_clear) @@ -3550,7 +3501,7 @@ API_FUNC(buffer_get_string) API_FUNC(buffer_get_pointer) { const char *buffer, *property; - char *result; + const char *result; API_INIT_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -3562,7 +3513,7 @@ API_FUNC(buffer_get_pointer) result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_set) @@ -3619,19 +3570,19 @@ API_FUNC(buffer_match_list) API_FUNC(current_window) { - char *result; + const char *result; API_INIT_FUNC(1, "current_window", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_search_with_buffer) { const char *buffer; - char *result; + const char *result; API_INIT_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -3641,7 +3592,7 @@ API_FUNC(window_search_with_buffer) result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(buffer))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_get_integer) @@ -3682,7 +3633,7 @@ API_FUNC(window_get_string) API_FUNC(window_get_pointer) { const char *window, *property; - char *result; + const char *result; API_INIT_FUNC(1, "window_get_pointer", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -3694,7 +3645,7 @@ API_FUNC(window_get_pointer) result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_set_title) @@ -3715,7 +3666,7 @@ API_FUNC(window_set_title) API_FUNC(nicklist_add_group) { const char *buffer, *parent_group, *name, *color; - char *result; + const char *result; int visible; API_INIT_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY); @@ -3734,13 +3685,13 @@ API_FUNC(nicklist_add_group) color, visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_group) { const char *buffer, *from_group, *name; - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -3754,13 +3705,13 @@ API_FUNC(nicklist_search_group) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_add_nick) { const char *buffer, *group, *name, *color, *prefix, *prefix_color; - char *result; + const char *result; int visible; API_INIT_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY); @@ -3783,13 +3734,13 @@ API_FUNC(nicklist_add_nick) prefix_color, visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_nick) { const char *buffer, *from_group, *name; - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -3803,7 +3754,7 @@ API_FUNC(nicklist_search_nick) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_remove_group) @@ -3897,7 +3848,7 @@ API_FUNC(nicklist_group_get_string) API_FUNC(nicklist_group_get_pointer) { const char *buffer, *group, *property; - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -3911,7 +3862,7 @@ API_FUNC(nicklist_group_get_pointer) API_STR2PTR(group), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_group_set) @@ -3977,7 +3928,7 @@ API_FUNC(nicklist_nick_get_string) API_FUNC(nicklist_nick_get_pointer) { const char *buffer, *nick, *property; - char *result; + const char *result; API_INIT_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -3991,7 +3942,7 @@ API_FUNC(nicklist_nick_get_pointer) API_STR2PTR(nick), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_nick_set) @@ -4018,7 +3969,7 @@ API_FUNC(nicklist_nick_set) API_FUNC(bar_item_search) { const char *name; - char *result; + const char *result; API_INIT_FUNC(1, "bar_item_search", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -4028,7 +3979,7 @@ API_FUNC(bar_item_search) result = API_PTR2STR(weechat_bar_item_search (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -4052,39 +4003,27 @@ weechat_lua_api_bar_item_build_cb (const void *pointer, void *data, { /* new callback: data, item, window, buffer, extra_info */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = extra_info; ret = (char *)weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function + 7, "ssssh", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); } else { /* old callback: data, item, window */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); ret = (char *)weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function, "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); } return ret; @@ -4096,7 +4035,7 @@ weechat_lua_api_bar_item_build_cb (const void *pointer, void *data, API_FUNC(bar_item_new) { const char *name, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "bar_item_new", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -4113,7 +4052,7 @@ API_FUNC(bar_item_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_item_update) @@ -4149,7 +4088,7 @@ API_FUNC(bar_item_remove) API_FUNC(bar_search) { const char *name; - char *result; + const char *result; API_INIT_FUNC(1, "bar_search", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -4159,7 +4098,7 @@ API_FUNC(bar_search) result = API_PTR2STR(weechat_bar_search (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_new) @@ -4167,7 +4106,7 @@ API_FUNC(bar_new) const char *name, *hidden, *priority, *type, *conditions, *position; const char *filling_top_bottom, *filling_left_right, *size, *size_max; const char *color_fg, *color_delim, *color_bg, *separator, *items; - char *result; + const char *result; API_INIT_FUNC(1, "bar_new", API_RETURN_EMPTY); if (lua_gettop (L) < 15) @@ -4205,7 +4144,7 @@ API_FUNC(bar_new) separator, items)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_set) @@ -4321,19 +4260,19 @@ API_FUNC(info_get_hashtable) API_FUNC(infolist_new) { - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new", API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_item) { const char *infolist; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_item", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -4343,13 +4282,13 @@ API_FUNC(infolist_new_item) result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(infolist))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_integer) { const char *item, *name; - char *result; + const char *result; int value; API_INIT_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY); @@ -4364,13 +4303,13 @@ API_FUNC(infolist_new_var_integer) name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_string) { const char *item, *name, *value; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -4384,13 +4323,13 @@ API_FUNC(infolist_new_var_string) name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_pointer) { const char *item, *name, *value; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -4404,13 +4343,13 @@ API_FUNC(infolist_new_var_pointer) name, API_STR2PTR(value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_time) { const char *item, *name; - char *result; + const char *result; int value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); @@ -4425,13 +4364,13 @@ API_FUNC(infolist_new_var_time) name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_search_var) { const char *infolist, *name; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_search_var", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -4443,13 +4382,13 @@ API_FUNC(infolist_search_var) result = API_PTR2STR(weechat_infolist_search_var (API_STR2PTR(infolist), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_get) { const char *name, *pointer, *arguments; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_get", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -4463,7 +4402,7 @@ API_FUNC(infolist_get) API_STR2PTR(pointer), arguments)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_next) @@ -4566,7 +4505,7 @@ API_FUNC(infolist_string) API_FUNC(infolist_pointer) { const char *infolist, *variable; - char *result; + const char *result; API_INIT_FUNC(1, "infolist_pointer", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -4578,7 +4517,7 @@ API_FUNC(infolist_pointer) result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), variable)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_time) @@ -4627,7 +4566,7 @@ API_FUNC(infolist_free) API_FUNC(hdata_get) { const char *name; - char *result; + const char *result; API_INIT_FUNC(1, "hdata_get", API_RETURN_EMPTY); if (lua_gettop (L) < 1) @@ -4637,7 +4576,7 @@ API_FUNC(hdata_get) result = API_PTR2STR(weechat_hdata_get (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_offset) @@ -4731,7 +4670,7 @@ API_FUNC(hdata_get_var_hdata) API_FUNC(hdata_get_list) { const char *hdata, *name; - char *result; + const char *result; API_INIT_FUNC(1, "hdata_get_list", API_RETURN_EMPTY); if (lua_gettop (L) < 2) @@ -4743,7 +4682,7 @@ API_FUNC(hdata_get_list) result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_check_pointer) @@ -4769,7 +4708,7 @@ API_FUNC(hdata_check_pointer) API_FUNC(hdata_move) { const char *hdata, *pointer; - char *result; + const char *result; int count; API_INIT_FUNC(1, "hdata_move", API_RETURN_EMPTY); @@ -4784,13 +4723,13 @@ API_FUNC(hdata_move) API_STR2PTR(pointer), count)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_search) { const char *hdata, *pointer, *search; - char *result; + const char *result; int move; API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY); @@ -4807,7 +4746,7 @@ API_FUNC(hdata_search) search, move)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_char) @@ -4892,7 +4831,7 @@ API_FUNC(hdata_string) API_FUNC(hdata_pointer) { const char *hdata, *pointer, *name; - char *result; + const char *result; API_INIT_FUNC(1, "hdata_pointer", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -4906,7 +4845,7 @@ API_FUNC(hdata_pointer) API_STR2PTR(pointer), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_time) @@ -5036,9 +4975,9 @@ weechat_lua_api_upgrade_read_cb (const void *pointer, void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); rc = (int *) weechat_lua_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -5052,10 +4991,6 @@ weechat_lua_api_upgrade_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -5066,7 +5001,7 @@ weechat_lua_api_upgrade_read_cb (const void *pointer, void *data, API_FUNC(upgrade_new) { const char *filename, *function, *data; - char *result; + const char *result; API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -5085,7 +5020,7 @@ API_FUNC(upgrade_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(upgrade_write_object) diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 5196794a8..2ac22a3a1 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -531,7 +531,7 @@ API_FUNC(mkdir_parents) API_FUNC(list_new) { - char *result; + const char *result; dXSARGS; /* make C compiler happy */ @@ -542,12 +542,13 @@ API_FUNC(list_new) result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_add) { - char *result, *weelist, *data, *where, *user_data; + char *weelist, *data, *where, *user_data; + const char *result; dXSARGS; API_INIT_FUNC(1, "list_add", API_RETURN_EMPTY); @@ -564,12 +565,13 @@ API_FUNC(list_add) where, API_STR2PTR(user_data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search) { - char *result, *weelist, *data; + char *weelist, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "list_search", API_RETURN_EMPTY); @@ -582,7 +584,7 @@ API_FUNC(list_search) result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search_pos) @@ -605,7 +607,8 @@ API_FUNC(list_search_pos) API_FUNC(list_casesearch) { - char *result, *weelist, *data; + char *weelist, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "list_casesearch", API_RETURN_EMPTY); @@ -618,7 +621,7 @@ API_FUNC(list_casesearch) result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_casesearch_pos) @@ -641,7 +644,7 @@ API_FUNC(list_casesearch_pos) API_FUNC(list_get) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "list_get", API_RETURN_EMPTY); @@ -651,7 +654,7 @@ API_FUNC(list_get) result = API_PTR2STR(weechat_list_get (API_STR2PTR(SvPV_nolen (ST (0))), /* weelist */ SvIV (ST (1)))); /* position */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_set) @@ -673,7 +676,7 @@ API_FUNC(list_set) API_FUNC(list_next) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "list_next", API_RETURN_EMPTY); @@ -682,12 +685,12 @@ API_FUNC(list_next) result = API_PTR2STR(weechat_list_next (API_STR2PTR(SvPV_nolen (ST (0))))); /* item */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_prev) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "list_prev", API_RETURN_EMPTY); @@ -696,7 +699,7 @@ API_FUNC(list_prev) result = API_PTR2STR(weechat_list_prev (API_STR2PTR(SvPV_nolen (ST (0))))); /* item */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_string) @@ -787,7 +790,7 @@ weechat_perl_api_config_reload_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); rc = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -801,8 +804,6 @@ weechat_perl_api_config_reload_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -812,7 +813,8 @@ weechat_perl_api_config_reload_cb (const void *pointer, void *data, API_FUNC(config_new) { - char *result, *name, *function, *data; + char *name, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "config_new", API_RETURN_EMPTY); @@ -830,7 +832,7 @@ API_FUNC(config_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -852,8 +854,8 @@ weechat_perl_api_config_section_read_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -869,10 +871,6 @@ weechat_perl_api_config_section_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -897,7 +895,7 @@ weechat_perl_api_config_section_write_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_perl_exec (script, @@ -912,8 +910,6 @@ weechat_perl_api_config_section_write_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -938,7 +934,7 @@ weechat_perl_api_config_section_write_default_cb (const void *pointer, void *dat if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_perl_exec (script, @@ -953,8 +949,6 @@ weechat_perl_api_config_section_write_default_cb (const void *pointer, void *dat ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -981,8 +975,8 @@ weechat_perl_api_config_section_create_option_cb (const void *pointer, void *dat if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -998,10 +992,6 @@ weechat_perl_api_config_section_create_option_cb (const void *pointer, void *dat ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1027,9 +1017,9 @@ weechat_perl_api_config_section_delete_option_cb (const void *pointer, void *dat if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); rc = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1043,12 +1033,6 @@ weechat_perl_api_config_section_delete_option_cb (const void *pointer, void *dat ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1058,10 +1042,11 @@ weechat_perl_api_config_section_delete_option_cb (const void *pointer, void *dat API_FUNC(config_new_section) { - char *result, *cfg_file, *name, *function_read, *data_read; + char *cfg_file, *name, *function_read, *data_read; char *function_write, *data_write, *function_write_default; char *data_write_default, *function_create_option, *data_create_option; char *function_delete_option, *data_delete_option; + const char *result; dXSARGS; @@ -1106,12 +1091,13 @@ API_FUNC(config_new_section) function_delete_option, data_delete_option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_section) { - char *result, *config_file, *section_name; + char *config_file, *section_name; + const char *result; dXSARGS; API_INIT_FUNC(1, "config_search_section", API_RETURN_EMPTY); @@ -1124,7 +1110,7 @@ API_FUNC(config_search_section) result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), section_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1144,7 +1130,7 @@ weechat_perl_api_config_option_check_value_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_perl_exec (script, @@ -1159,8 +1145,6 @@ weechat_perl_api_config_option_check_value_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1184,16 +1168,13 @@ weechat_perl_api_config_option_change_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1215,16 +1196,13 @@ weechat_perl_api_config_option_delete_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1232,10 +1210,11 @@ weechat_perl_api_config_option_delete_cb (const void *pointer, void *data, API_FUNC(config_new_option) { - char *result, *config_file, *section, *name, *type; + char *config_file, *section, *name, *type; char *description, *string_values, *default_value, *value; char *function_check_value, *data_check_value, *function_change; char *data_change, *function_delete, *data_delete; + const char *result; dXSARGS; API_INIT_FUNC(1, "config_new_option", API_RETURN_EMPTY); @@ -1280,12 +1259,13 @@ API_FUNC(config_new_option) function_delete, data_delete)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_option) { - char *result, *config_file, *section, *option_name; + char *config_file, *section, *option_name; + const char *result; dXSARGS; API_INIT_FUNC(1, "config_search_option", API_RETURN_EMPTY); @@ -1300,7 +1280,7 @@ API_FUNC(config_search_option) API_STR2PTR(section), option_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_string_to_boolean) @@ -1683,7 +1663,7 @@ API_FUNC(config_free) API_FUNC(config_get) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "config_get", API_RETURN_EMPTY); @@ -1692,7 +1672,7 @@ API_FUNC(config_get) result = API_PTR2STR(weechat_config_get (SvPV_nolen (ST (0)))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_get_plugin) @@ -1961,7 +1941,7 @@ weechat_perl_api_hook_command_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_perl_exec (script, @@ -1976,8 +1956,6 @@ weechat_perl_api_hook_command_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1987,8 +1965,9 @@ weechat_perl_api_hook_command_cb (const void *pointer, void *data, API_FUNC(hook_command) { - char *result, *command, *description, *args, *args_description; + char *command, *description, *args, *args_description; char *completion, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_command", API_RETURN_EMPTY); @@ -2014,7 +1993,7 @@ API_FUNC(hook_command) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2036,8 +2015,8 @@ weechat_perl_api_hook_completion_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); rc = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -2051,10 +2030,6 @@ weechat_perl_api_hook_completion_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -2064,7 +2039,8 @@ weechat_perl_api_hook_completion_cb (const void *pointer, void *data, API_FUNC(hook_completion) { - char *result, *completion, *description, *function, *data; + char *completion, *description, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY); @@ -2084,7 +2060,7 @@ API_FUNC(hook_completion) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_completion_get_string) @@ -2144,7 +2120,7 @@ weechat_perl_api_hook_command_run_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_perl_exec (script, @@ -2159,8 +2135,6 @@ weechat_perl_api_hook_command_run_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2170,7 +2144,8 @@ weechat_perl_api_hook_command_run_cb (const void *pointer, void *data, API_FUNC(hook_command_run) { - char *result, *command, *function, *data; + char *command, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_command_run", API_RETURN_EMPTY); @@ -2188,7 +2163,7 @@ API_FUNC(hook_command_run) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2233,7 +2208,7 @@ weechat_perl_api_hook_timer_cb (const void *pointer, void *data, API_FUNC(hook_timer) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); @@ -2249,7 +2224,7 @@ API_FUNC(hook_timer) SvPV_nolen (ST (3)), /* perl function */ SvPV_nolen (ST (4)))); /* data */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2290,7 +2265,7 @@ weechat_perl_api_hook_fd_cb (const void *pointer, void *data, int fd) API_FUNC(hook_fd) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_fd", API_RETURN_EMPTY); @@ -2307,7 +2282,7 @@ API_FUNC(hook_fd) SvPV_nolen (ST (4)), /* perl function */ SvPV_nolen (ST (5)))); /* data */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2372,7 +2347,8 @@ weechat_perl_api_hook_process_cb (const void *pointer, void *data, API_FUNC(hook_process) { - char *command, *function, *data, *result; + char *command, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_process", API_RETURN_EMPTY); @@ -2391,12 +2367,13 @@ API_FUNC(hook_process) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_process_hashtable) { - char *command, *function, *data, *result; + char *command, *function, *data; + const char *result; struct t_hashtable *options; dXSARGS; @@ -2424,7 +2401,7 @@ API_FUNC(hook_process_hashtable) if (options) weechat_hashtable_free (options); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2472,7 +2449,8 @@ weechat_perl_api_hook_connect_cb (const void *pointer, void *data, API_FUNC(hook_connect) { - char *proxy, *address, *local_hostname, *function, *data, *result; + char *proxy, *address, *local_hostname, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_connect", API_RETURN_EMPTY); @@ -2501,7 +2479,7 @@ API_FUNC(hook_connect) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2530,7 +2508,7 @@ weechat_perl_api_hook_print_cb (const void *pointer, void *data, snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2552,8 +2530,6 @@ weechat_perl_api_hook_print_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); if (func_argv[3]) free (func_argv[3]); @@ -2565,7 +2541,8 @@ weechat_perl_api_hook_print_cb (const void *pointer, void *data, API_FUNC(hook_print) { - char *result, *buffer, *tags, *message, *function, *data; + char *buffer, *tags, *message, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_print", API_RETURN_EMPTY); @@ -2588,7 +2565,7 @@ API_FUNC(hook_print) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2601,7 +2578,7 @@ weechat_perl_api_hook_signal_cb (const void *pointer, void *data, char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; static char str_value[64]; - int *rc, ret, free_needed; + int *rc, ret; script = (struct t_plugin_script *)pointer; plugin_script_get_function_and_data (data, &ptr_function, &ptr_data); @@ -2610,7 +2587,6 @@ weechat_perl_api_hook_signal_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (signal) ? (char *)signal : empty_arg; - free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; @@ -2627,8 +2603,7 @@ weechat_perl_api_hook_signal_cb (const void *pointer, void *data, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = API_PTR2STR(signal_data); - free_needed = 1; + func_argv[2] = (char *)API_PTR2STR(signal_data); } else func_argv[2] = empty_arg; @@ -2645,8 +2620,6 @@ weechat_perl_api_hook_signal_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (free_needed && func_argv[2]) - free (func_argv[2]); return ret; } @@ -2656,7 +2629,8 @@ weechat_perl_api_hook_signal_cb (const void *pointer, void *data, API_FUNC(hook_signal) { - char *result, *signal, *function, *data; + char *signal, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_signal", API_RETURN_EMPTY); @@ -2674,7 +2648,7 @@ API_FUNC(hook_signal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_signal_send) @@ -2756,7 +2730,8 @@ weechat_perl_api_hook_hsignal_cb (const void *pointer, void *data, API_FUNC(hook_hsignal) { - char *result, *signal, *function, *data; + char *signal, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_hsignal", API_RETURN_EMPTY); @@ -2774,7 +2749,7 @@ API_FUNC(hook_hsignal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_hsignal_send) @@ -2842,7 +2817,8 @@ weechat_perl_api_hook_config_cb (const void *pointer, void *data, API_FUNC(hook_config) { - char *result, *option, *function, *data; + char *option, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_config", API_RETURN_EMPTY); @@ -2860,7 +2836,7 @@ API_FUNC(hook_config) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -2895,7 +2871,8 @@ weechat_perl_api_hook_modifier_cb (const void *pointer, void *data, API_FUNC(hook_modifier) { - char *result, *modifier, *function, *data; + char *modifier, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_modifier", API_RETURN_EMPTY); @@ -2913,7 +2890,7 @@ API_FUNC(hook_modifier) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_modifier_exec) @@ -2964,7 +2941,8 @@ weechat_perl_api_hook_info_cb (const void *pointer, void *data, API_FUNC(hook_info) { - char *result, *info_name, *description, *args_description, *function, *data; + char *info_name, *description, *args_description, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_info", API_RETURN_EMPTY); @@ -2986,7 +2964,7 @@ API_FUNC(hook_info) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3020,8 +2998,9 @@ weechat_perl_api_hook_info_hashtable_cb (const void *pointer, void *data, API_FUNC(hook_info_hashtable) { - char *result, *info_name, *description, *args_description; + char *info_name, *description, *args_description; char *output_description, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY); @@ -3045,7 +3024,7 @@ API_FUNC(hook_info_hashtable) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_infolist * @@ -3066,7 +3045,7 @@ weechat_perl_api_hook_infolist_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_perl_exec ( @@ -3075,9 +3054,6 @@ weechat_perl_api_hook_infolist_cb (const void *pointer, void *data, ptr_function, "ssss", func_argv); - if (func_argv[2]) - free (func_argv[2]); - return result; } @@ -3086,8 +3062,9 @@ weechat_perl_api_hook_infolist_cb (const void *pointer, void *data, API_FUNC(hook_infolist) { - char *result, *infolist_name, *description, *pointer_description; + char *infolist_name, *description, *pointer_description; char *args_description, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_infolist", API_RETURN_EMPTY); @@ -3111,7 +3088,7 @@ API_FUNC(hook_infolist) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3143,7 +3120,8 @@ weechat_perl_api_hook_focus_cb (const void *pointer, void *data, API_FUNC(hook_focus) { - char *result, *area, *function, *data; + char *area, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "hook_focus", API_RETURN_EMPTY); @@ -3161,7 +3139,7 @@ API_FUNC(hook_focus) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_set) @@ -3227,7 +3205,7 @@ weechat_perl_api_buffer_input_data_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_perl_exec (script, @@ -3241,8 +3219,6 @@ weechat_perl_api_buffer_input_data_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3266,7 +3242,7 @@ weechat_perl_api_buffer_close_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); rc = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -3279,8 +3255,6 @@ weechat_perl_api_buffer_close_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3290,8 +3264,8 @@ weechat_perl_api_buffer_close_cb (const void *pointer, void *data, API_FUNC(buffer_new) { - char *result, *name, *function_input, *data_input, *function_close; - char *data_close; + char *name, *function_input, *data_input, *function_close, *data_close; + const char *result; dXSARGS; API_INIT_FUNC(1, "buffer_new", API_RETURN_EMPTY); @@ -3314,12 +3288,13 @@ API_FUNC(buffer_new) function_close, data_close)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search) { - char *result, *plugin, *name; + char *plugin, *name; + const char *result; dXSARGS; API_INIT_FUNC(1, "buffer_search", API_RETURN_EMPTY); @@ -3331,12 +3306,12 @@ API_FUNC(buffer_search) result = API_PTR2STR(weechat_buffer_search (plugin, name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search_main) { - char *result; + const char *result; dXSARGS; /* make C compiler happy */ @@ -3347,12 +3322,12 @@ API_FUNC(buffer_search_main) result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(current_buffer) { - char *result; + const char *result; dXSARGS; /* make C compiler happy */ @@ -3363,7 +3338,7 @@ API_FUNC(current_buffer) result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_clear) @@ -3458,7 +3433,8 @@ API_FUNC(buffer_get_string) API_FUNC(buffer_get_pointer) { - char *result, *buffer, *property; + char *buffer, *property; + const char *result; dXSARGS; API_INIT_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY); @@ -3471,7 +3447,7 @@ API_FUNC(buffer_get_pointer) result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_set) @@ -3529,7 +3505,7 @@ API_FUNC(buffer_match_list) API_FUNC(current_window) { - char *result; + const char *result; dXSARGS; /* make C compiler happy */ @@ -3540,12 +3516,12 @@ API_FUNC(current_window) result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_search_with_buffer) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY); @@ -3554,7 +3530,7 @@ API_FUNC(window_search_with_buffer) result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(SvPV_nolen (ST (0))))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } @@ -3596,7 +3572,8 @@ API_FUNC(window_get_string) API_FUNC(window_get_pointer) { - char *result, *window, *property; + char *window, *property; + const char *result; dXSARGS; API_INIT_FUNC(1, "window_get_pointer", API_RETURN_EMPTY); @@ -3609,7 +3586,7 @@ API_FUNC(window_get_pointer) result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_set_title) @@ -3627,7 +3604,8 @@ API_FUNC(window_set_title) API_FUNC(nicklist_add_group) { - char *result, *buffer, *parent_group, *name, *color; + char *buffer, *parent_group, *name, *color; + const char *result; dXSARGS; API_INIT_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY); @@ -3645,12 +3623,13 @@ API_FUNC(nicklist_add_group) color, SvIV (ST (4)))); /* visible */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_group) { - char *result, *buffer, *from_group, *name; + char *buffer, *from_group, *name; + const char *result; dXSARGS; API_INIT_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY); @@ -3665,12 +3644,13 @@ API_FUNC(nicklist_search_group) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_add_nick) { - char *result, *buffer, *group, *name, *color, *prefix, *prefix_color; + char *buffer, *group, *name, *color, *prefix, *prefix_color; + const char *result; dXSARGS; API_INIT_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY); @@ -3692,12 +3672,13 @@ API_FUNC(nicklist_add_nick) prefix_color, SvIV (ST (6)))); /* visible */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_nick) { - char *result, *buffer, *from_group, *name; + char *buffer, *from_group, *name; + const char *result; dXSARGS; API_INIT_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY); @@ -3712,7 +3693,7 @@ API_FUNC(nicklist_search_nick) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_remove_group) @@ -3808,7 +3789,8 @@ API_FUNC(nicklist_group_get_string) API_FUNC(nicklist_group_get_pointer) { - char *result, *buffer, *group, *property; + char *buffer, *group, *property; + const char *result; dXSARGS; API_INIT_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY); @@ -3823,7 +3805,7 @@ API_FUNC(nicklist_group_get_pointer) API_STR2PTR(group), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_group_set) @@ -3892,7 +3874,8 @@ API_FUNC(nicklist_nick_get_string) API_FUNC(nicklist_nick_get_pointer) { - char *result, *buffer, *nick, *property; + char *buffer, *nick, *property; + const char *result; dXSARGS; API_INIT_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY); @@ -3907,7 +3890,7 @@ API_FUNC(nicklist_nick_get_pointer) API_STR2PTR(nick), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_nick_set) @@ -3934,7 +3917,7 @@ API_FUNC(nicklist_nick_set) API_FUNC(bar_item_search) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "bar_item_search", API_RETURN_EMPTY); @@ -3943,7 +3926,7 @@ API_FUNC(bar_item_search) result = API_PTR2STR(weechat_bar_item_search (SvPV_nolen (ST (0)))); /* name */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -3967,39 +3950,27 @@ weechat_perl_api_bar_item_build_cb (const void *pointer, void *data, { /* new callback: data, item, window, buffer, extra_info */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = extra_info; ret = (char *)weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function + 7, "ssssh", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); } else { /* old callback: data, item, window */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); ret = (char *)weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function, "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); } return ret; @@ -4010,7 +3981,8 @@ weechat_perl_api_bar_item_build_cb (const void *pointer, void *data, API_FUNC(bar_item_new) { - char *result, *name, *function, *data; + char *name, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "bar_item_new", API_RETURN_EMPTY); @@ -4028,7 +4000,7 @@ API_FUNC(bar_item_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_item_update) @@ -4059,7 +4031,7 @@ API_FUNC(bar_item_remove) API_FUNC(bar_search) { - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "bar_search", API_RETURN_EMPTY); @@ -4068,14 +4040,15 @@ API_FUNC(bar_search) result = API_PTR2STR(weechat_bar_search (SvPV_nolen (ST (0)))); /* name */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_new) { - char *result, *name, *hidden, *priority, *type, *conditions, *position; + char *name, *hidden, *priority, *type, *conditions, *position; char *filling_top_bottom, *filling_left_right, *size, *size_max, *color_fg; char *color_delim, *color_bg, *separator, *bar_items; + const char *result; dXSARGS; API_INIT_FUNC(1, "bar_new", API_RETURN_EMPTY); @@ -4114,7 +4087,7 @@ API_FUNC(bar_new) separator, bar_items)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_set) @@ -4231,7 +4204,7 @@ API_FUNC(info_get_hashtable) API_FUNC(infolist_new) { - char *result; + const char *result; dXSARGS; /* make C compiler happy */ @@ -4242,12 +4215,13 @@ API_FUNC(infolist_new) result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_item) { - char *infolist, *result; + char *infolist; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_new_item", API_RETURN_EMPTY); @@ -4258,12 +4232,13 @@ API_FUNC(infolist_new_item) result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(infolist))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_integer) { - char *item, *name, *result; + char *item, *name; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY); @@ -4277,12 +4252,13 @@ API_FUNC(infolist_new_var_integer) name, SvIV (ST (2)))); /* value */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_string) { - char *item, *name, *value, *result; + char *item, *name, *value; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY); @@ -4297,12 +4273,13 @@ API_FUNC(infolist_new_var_string) name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_pointer) { - char *item, *name, *value, *result; + char *item, *name, *value; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY); @@ -4317,12 +4294,13 @@ API_FUNC(infolist_new_var_pointer) name, API_STR2PTR(value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_time) { - char *item, *name, *result; + char *item, *name; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); @@ -4336,12 +4314,13 @@ API_FUNC(infolist_new_var_time) name, SvIV (ST (2)))); /* value */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_search_var) { - char *infolist, *name, *result; + char *infolist, *name; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_search_var", API_RETURN_EMPTY); @@ -4354,12 +4333,13 @@ API_FUNC(infolist_search_var) result = API_PTR2STR(weechat_infolist_search_var (API_STR2PTR(infolist), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_get) { - char *result, *name, *pointer, *arguments; + char *name, *pointer, *arguments; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_get", API_RETURN_EMPTY); @@ -4374,7 +4354,7 @@ API_FUNC(infolist_get) API_STR2PTR(pointer), arguments)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_next) @@ -4471,7 +4451,7 @@ API_FUNC(infolist_string) API_FUNC(infolist_pointer) { char *infolist, *variable; - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "infolist_pointer", API_RETURN_EMPTY); @@ -4483,7 +4463,7 @@ API_FUNC(infolist_pointer) result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), variable)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_time) @@ -4528,7 +4508,8 @@ API_FUNC(infolist_free) API_FUNC(hdata_get) { - char *result, *name; + char *name; + const char *result; dXSARGS; API_INIT_FUNC(1, "hdata_get", API_RETURN_EMPTY); @@ -4539,7 +4520,7 @@ API_FUNC(hdata_get) result = API_PTR2STR(weechat_hdata_get (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_offset) @@ -4641,7 +4622,7 @@ API_FUNC(hdata_get_var_hdata) API_FUNC(hdata_get_list) { char *hdata, *name; - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "hdata_get_list", API_RETURN_EMPTY); @@ -4654,7 +4635,7 @@ API_FUNC(hdata_get_list) result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_check_pointer) @@ -4680,7 +4661,8 @@ API_FUNC(hdata_check_pointer) API_FUNC(hdata_move) { - char *result, *hdata, *pointer; + char *hdata, *pointer; + const char *result; int count; dXSARGS; @@ -4696,12 +4678,13 @@ API_FUNC(hdata_move) API_STR2PTR(pointer), count)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_search) { - char *result, *hdata, *pointer, *search; + char *hdata, *pointer, *search; + const char *result; int move; dXSARGS; @@ -4719,7 +4702,7 @@ API_FUNC(hdata_search) search, move)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_char) @@ -4809,7 +4792,7 @@ API_FUNC(hdata_string) API_FUNC(hdata_pointer) { char *hdata, *pointer, *name; - char *result; + const char *result; dXSARGS; API_INIT_FUNC(1, "hdata_pointer", API_RETURN_EMPTY); @@ -4824,7 +4807,7 @@ API_FUNC(hdata_pointer) API_STR2PTR(pointer), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_time) @@ -4959,9 +4942,9 @@ weechat_perl_api_upgrade_read_cb (const void *pointer, void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); rc = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -4975,10 +4958,6 @@ weechat_perl_api_upgrade_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -4988,7 +4967,8 @@ weechat_perl_api_upgrade_read_cb (const void *pointer, void *data, API_FUNC(upgrade_new) { - char *result, *filename, *function, *data; + char *filename, *function, *data; + const char *result; dXSARGS; API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY); @@ -5008,7 +4988,7 @@ API_FUNC(upgrade_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(upgrade_write_object) diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 4ad86fea7..521876425 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -83,7 +83,7 @@ #define API_RETURN_INT(__int) RETURN_LONG(__int) #define API_RETURN_LONG(__long) RETURN_LONG(__long) #define weechat_php_get_function_name(__zfunc, __str) \ - char *(__str); \ + const char *(__str); \ do \ { \ if (!zend_is_callable (__zfunc, 0, NULL)) \ @@ -106,7 +106,7 @@ API_FUNC(register) { zend_string *name, *author, *version, *license, *description, *charset; zval *shutdown_func; - char *shutdown_func_name; + const char *shutdown_func_name; API_INIT_FUNC(0, "register", API_RETURN_ERROR); if (php_registered_script) @@ -252,7 +252,7 @@ API_FUNC(plugin_get_name) { zend_string *z_plugin; struct t_weechat_plugin *plugin; - const char *retval; + const char *result; API_INIT_FUNC(1, "plugin_get_name", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_plugin) == FAILURE) @@ -260,9 +260,9 @@ API_FUNC(plugin_get_name) plugin = API_STR2PTR(ZSTR_VAL(z_plugin)); - retval = weechat_plugin_get_name (plugin); + result = weechat_plugin_get_name (plugin); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(charset_set) @@ -283,7 +283,7 @@ API_FUNC(charset_set) API_FUNC(iconv_to_internal) { zend_string *z_charset, *z_string; - char *charset, *string, *retval; + char *charset, *string, *result; API_INIT_FUNC(1, "iconv_to_internal", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -292,16 +292,16 @@ API_FUNC(iconv_to_internal) charset = ZSTR_VAL(z_charset); string = ZSTR_VAL(z_string); - retval = weechat_iconv_to_internal ((const char *)charset, + result = weechat_iconv_to_internal ((const char *)charset, (const char *)string); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(iconv_from_internal) { zend_string *z_charset, *z_string; - char *charset, *string, *retval; + char *charset, *string, *result; API_INIT_FUNC(1, "iconv_from_internal", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -310,26 +310,26 @@ API_FUNC(iconv_from_internal) charset = ZSTR_VAL(z_charset); string = ZSTR_VAL(z_string); - retval = weechat_iconv_from_internal ((const char *)charset, + result = weechat_iconv_from_internal ((const char *)charset, (const char *)string); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(gettext) { zend_string *z_string; char *string; - const char *retval; + const char *result; API_INIT_FUNC(1, "gettext", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_string) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); string = ZSTR_VAL(z_string); - retval = weechat_gettext ((const char *)string); + result = weechat_gettext ((const char *)string); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(ngettext) @@ -338,7 +338,7 @@ API_FUNC(ngettext) zend_long z_count; char *single, *plural; int count; - const char *retval; + const char *result; API_INIT_FUNC(1, "ngettext", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -349,18 +349,18 @@ API_FUNC(ngettext) single = ZSTR_VAL(z_single); plural = ZSTR_VAL(z_plural); count = (int)z_count; - retval = weechat_ngettext ((const char *)single, + result = weechat_ngettext ((const char *)single, (const char *)plural, count); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(strlen_screen) { zend_string *z_string; char *string; - int retval; + int result; API_INIT_FUNC(1, "strlen_screen", API_RETURN_INT(0)); @@ -368,16 +368,16 @@ API_FUNC(strlen_screen) API_WRONG_ARGS(API_RETURN_INT(0)); string = ZSTR_VAL(z_string); - retval = weechat_strlen_screen ((const char *)string); + result = weechat_strlen_screen ((const char *)string); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(string_match) { zend_string *z_string, *z_mask; zend_long z_case_sensitive; - int case_sensitive, retval; + int case_sensitive, result; char *string, *mask; API_INIT_FUNC(1, "string_match", API_RETURN_INT(0)); @@ -389,18 +389,18 @@ API_FUNC(string_match) string = ZSTR_VAL(z_string); mask = ZSTR_VAL(z_mask); case_sensitive = (int)z_case_sensitive; - retval = weechat_string_match ((const char *)string, + result = weechat_string_match ((const char *)string, (const char *)mask, case_sensitive); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(string_has_highlight) { zend_string *z_string, *z_highlight_words; char *string, *highlight_words; - int retval; + int result; API_INIT_FUNC(1, "string_has_highlight", API_RETURN_INT(0)); @@ -410,17 +410,17 @@ API_FUNC(string_has_highlight) string = ZSTR_VAL(z_string); highlight_words = ZSTR_VAL(z_highlight_words); - retval = weechat_string_has_highlight ((const char *)string, + result = weechat_string_has_highlight ((const char *)string, (const char *)highlight_words); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(string_has_highlight_regex) { zend_string *z_string, *z_regex; char *string, *regex; - int retval; + int result; API_INIT_FUNC(1, "string_has_highlight_regex", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -429,16 +429,16 @@ API_FUNC(string_has_highlight_regex) string = ZSTR_VAL(z_string); regex = ZSTR_VAL(z_regex); - retval = weechat_string_has_highlight_regex ((const char *)string, + result = weechat_string_has_highlight_regex ((const char *)string, (const char *)regex); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(string_mask_to_regex) { zend_string *z_mask; - char *mask, *retval; + char *mask, *result; API_INIT_FUNC(1, "string_mask_to_regex", API_RETURN_EMPTY); @@ -446,30 +446,30 @@ API_FUNC(string_mask_to_regex) API_WRONG_ARGS(API_RETURN_EMPTY); mask = ZSTR_VAL(z_mask); - retval = weechat_string_mask_to_regex ((const char *)mask); + result = weechat_string_mask_to_regex ((const char *)mask); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(string_format_size) { zend_long z_size; - char *retval; + char *result; API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "l", &z_size) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); - retval = weechat_string_format_size ((unsigned long long)z_size); + result = weechat_string_format_size ((unsigned long long)z_size); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(string_remove_color) { zend_string *z_string, *z_replacement; - char *string, *replacement, *retval; + char *string, *replacement, *result; API_INIT_FUNC(1, "string_remove_color", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -478,49 +478,49 @@ API_FUNC(string_remove_color) string = ZSTR_VAL(z_string); replacement = ZSTR_VAL(z_replacement); - retval = weechat_string_remove_color ((const char *)string, + result = weechat_string_remove_color ((const char *)string, (const char *)replacement); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(string_is_command_char) { zend_string *z_string; char *string; - int retval; + int result; API_INIT_FUNC(1, "string_is_command_char", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_string) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); string = ZSTR_VAL(z_string); - retval = weechat_string_is_command_char ((const char *)string); + result = weechat_string_is_command_char ((const char *)string); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(string_input_for_buffer) { zend_string *z_string; char *string; - const char *retval; + const char *result; API_INIT_FUNC(1, "string_input_for_buffer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_string) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); string = ZSTR_VAL(z_string); - retval = weechat_string_input_for_buffer ((const char *)string); + result = weechat_string_input_for_buffer ((const char *)string); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(string_eval_expression) { zend_string *z_expr; zval *z_pointers, *z_extra_vars, *z_options; - char *expr, *retval; + char *expr, *result; struct t_hashtable *pointers, *extra_vars, *options; API_INIT_FUNC(1, "string_eval_expression", API_RETURN_EMPTY); @@ -545,19 +545,19 @@ API_FUNC(string_eval_expression) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); - retval = weechat_string_eval_expression ((const char *)expr, + result = weechat_string_eval_expression ((const char *)expr, pointers, extra_vars, options); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(string_eval_path_home) { zend_string *z_path; zval *z_pointers, *z_extra_vars, *z_options; - char *path, *retval; + char *path, *result; struct t_hashtable *pointers, *extra_vars, *options; API_INIT_FUNC(1, "string_eval_path_home", API_RETURN_EMPTY); @@ -582,12 +582,12 @@ API_FUNC(string_eval_path_home) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); - retval = weechat_string_eval_path_home ((const char *)path, + result = weechat_string_eval_path_home ((const char *)path, pointers, extra_vars, options); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(mkdir_home) @@ -652,16 +652,15 @@ API_FUNC(mkdir_parents) API_FUNC(list_new) { - struct t_weelist *retval; + const char *result; API_INIT_FUNC(1, "list_new", API_RETURN_EMPTY); if (zend_parse_parameters_none () == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); - retval = weechat_list_new (); - char *__retstr = API_PTR2STR(retval); + result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(__retstr); + API_RETURN_STRING(result); } API_FUNC(list_add) @@ -670,7 +669,7 @@ API_FUNC(list_add) struct t_weelist *weelist; char *data, *where; void *user_data; - struct t_weelist_item *retval; + const char *result; API_INIT_FUNC(1, "list_add", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -682,13 +681,13 @@ API_FUNC(list_add) data = ZSTR_VAL(z_data); where = ZSTR_VAL(z_where); user_data = (void *)API_STR2PTR(ZSTR_VAL(z_user_data)); - retval = weechat_list_add (weelist, - (const char *)data, - (const char *)where, - user_data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_list_add (weelist, + (const char *)data, + (const char *)where, + user_data)); + + API_RETURN_STRING(result); } API_FUNC(list_search) @@ -696,7 +695,7 @@ API_FUNC(list_search) zend_string *z_weelist, *z_data; struct t_weelist *weelist; char *data; - struct t_weelist_item *retval; + const char *result; API_INIT_FUNC(1, "list_search", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -705,10 +704,10 @@ API_FUNC(list_search) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); data = ZSTR_VAL(z_data); - retval = weechat_list_search (weelist, (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_list_search (weelist, (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(list_search_pos) @@ -716,7 +715,7 @@ API_FUNC(list_search_pos) zend_string *z_weelist, *z_data; struct t_weelist *weelist; char *data; - int retval; + int result; API_INIT_FUNC(1, "list_search_pos", API_RETURN_INT(-1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -725,9 +724,9 @@ API_FUNC(list_search_pos) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); data = ZSTR_VAL(z_data); - retval = weechat_list_search_pos (weelist, (const char *)data); + result = weechat_list_search_pos (weelist, (const char *)data); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(list_casesearch) @@ -735,7 +734,7 @@ API_FUNC(list_casesearch) zend_string *z_weelist, *z_data; struct t_weelist *weelist; char *data; - struct t_weelist_item *retval; + const char *result; API_INIT_FUNC(1, "list_casesearch", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -744,10 +743,11 @@ API_FUNC(list_casesearch) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); data = ZSTR_VAL(z_data); - retval = weechat_list_casesearch (weelist, (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_list_casesearch (weelist, (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(list_casesearch_pos) @@ -755,7 +755,7 @@ API_FUNC(list_casesearch_pos) zend_string *z_weelist, *z_data; struct t_weelist *weelist; char *data; - int retval; + int result; API_INIT_FUNC(1, "list_casesearch_pos", API_RETURN_INT(-1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -764,9 +764,9 @@ API_FUNC(list_casesearch_pos) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); data = ZSTR_VAL(z_data); - retval = weechat_list_casesearch_pos (weelist, (const char *)data); + result = weechat_list_casesearch_pos (weelist, (const char *)data); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(list_get) @@ -775,7 +775,7 @@ API_FUNC(list_get) zend_long z_position; struct t_weelist *weelist; int position; - struct t_weelist_item *retval; + const char *result; API_INIT_FUNC(1, "list_get", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -784,10 +784,10 @@ API_FUNC(list_get) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); position = (int)z_position; - retval = weechat_list_get (weelist, position); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_list_get (weelist, position)); + + API_RETURN_STRING(result); } API_FUNC(list_set) @@ -811,23 +811,25 @@ API_FUNC(list_set) API_FUNC(list_next) { zend_string *z_item; - struct t_weelist_item *item, *retval; + struct t_weelist_item *item; + const char *result; API_INIT_FUNC(1, "list_next", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_item) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item)); - retval = weechat_list_next (item); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_list_next (item)); + + API_RETURN_STRING(result); } API_FUNC(list_prev) { zend_string *z_item; - struct t_weelist_item *item, *retval; + struct t_weelist_item *item; + const char *result; API_INIT_FUNC(1, "list_prev", API_RETURN_EMPTY); @@ -835,16 +837,16 @@ API_FUNC(list_prev) API_WRONG_ARGS(API_RETURN_EMPTY); item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item)); - retval = weechat_list_prev (item); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_list_prev (item)); + + API_RETURN_STRING(result); } API_FUNC(list_string) { zend_string *z_item; - const char *retval; + const char *result; struct t_weelist_item *item; API_INIT_FUNC(1, "list_string", API_RETURN_EMPTY); @@ -852,25 +854,25 @@ API_FUNC(list_string) API_WRONG_ARGS(API_RETURN_EMPTY); item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item)); - retval = weechat_list_string (item); + result = weechat_list_string (item); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(list_size) { zend_string *z_weelist; struct t_weelist *weelist; - int retval; + int result; API_INIT_FUNC(1, "list_size", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_weelist) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); - retval = weechat_list_size (weelist); + result = weechat_list_size (weelist); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(list_remove) @@ -929,14 +931,11 @@ weechat_php_api_config_reload_cb (const void *pointer, void *data, int rc; void *func_argv[2]; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); weechat_php_cb (pointer, data, func_argv, "ss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -946,7 +945,7 @@ API_FUNC(config_new) zval *z_callback_reload; zend_string *z_data; char *name, *data; - struct t_config_file *retval; + const char *result; API_INIT_FUNC(1, "config_new", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -957,16 +956,17 @@ API_FUNC(config_new) name = ZSTR_VAL(z_name); weechat_php_get_function_name (z_callback_reload, callback_reload_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_config_new ( - weechat_php_plugin, - php_current_script, - (const char *)name, - &weechat_php_api_config_reload_cb, - (const char *)callback_reload_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_config_new ( + weechat_php_plugin, + php_current_script, + (const char *)name, + &weechat_php_api_config_reload_cb, + (const char *)callback_reload_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -979,19 +979,14 @@ weechat_php_api_config_section_read_cb (const void *pointer, void *data, int rc; void *func_argv[5]; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = option_name ? (char *)option_name : weechat_php_empty_arg; func_argv[4] = value ? (char *)value : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sssss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - return rc; } @@ -1003,15 +998,12 @@ weechat_php_api_config_section_write_cb (const void *pointer, void *data, int rc; void *func_argv[3]; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = section_name ? (char *)section_name : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -1024,15 +1016,12 @@ weechat_php_api_config_section_write_default_cb (const void *pointer, int rc; void *func_argv[3]; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = section_name ? (char *)section_name : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -1047,19 +1036,14 @@ weechat_php_api_config_section_create_option_cb (const void *pointer, int rc; void *func_argv[5]; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = option_name ? (char *)option_name : weechat_php_empty_arg; func_argv[4] = value ? (char *)value : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sssss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - return rc; } @@ -1073,20 +1057,13 @@ weechat_php_api_config_section_delete_option_cb (const void *pointer, int rc; void *func_argv[4]; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); weechat_php_cb (pointer, data, func_argv, "ssss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); - return rc; } @@ -1098,12 +1075,12 @@ API_FUNC(config_new_section) zval *z_callback_create_option, *z_callback_delete_option; zend_string *z_data_read, *z_data_write, *z_data_write_default; zend_string *z_data_create_option, *z_data_delete_option; - struct t_config_section *retval; struct t_config_file *config_file; char *name; int user_can_add_options, user_can_delete_options; char *data_read, *data_write, *data_write_default; char *data_create_option, *data_delete_option; + const char *result; API_INIT_FUNC(1, "config_new_section", API_RETURN_EMPTY); if (zend_parse_parameters ( @@ -1132,31 +1109,32 @@ API_FUNC(config_new_section) weechat_php_get_function_name (z_callback_delete_option, callback_delete_option_name); data_delete_option = ZSTR_VAL(z_data_delete_option); - retval = plugin_script_api_config_new_section ( - weechat_php_plugin, - php_current_script, - config_file, - (const char *)name, - user_can_add_options, - user_can_delete_options, - &weechat_php_api_config_section_read_cb, - (const char *)callback_read_name, - (const char *)data_read, - &weechat_php_api_config_section_write_cb, - (const char *)callback_write_name, - (const char *)data_write, - &weechat_php_api_config_section_write_default_cb, - (const char *)callback_write_default_name, - (const char *)data_write_default, - &weechat_php_api_config_section_create_option_cb, - (const char *)callback_create_option_name, - (const char *)data_create_option, - &weechat_php_api_config_section_delete_option_cb, - (const char *)callback_delete_option_name, - (const char *)data_delete_option); - char *__retstr = API_PTR2STR(retval); - - API_RETURN_STRING_FREE(__retstr); + + result = API_PTR2STR( + plugin_script_api_config_new_section ( + weechat_php_plugin, + php_current_script, + config_file, + (const char *)name, + user_can_add_options, + user_can_delete_options, + &weechat_php_api_config_section_read_cb, + (const char *)callback_read_name, + (const char *)data_read, + &weechat_php_api_config_section_write_cb, + (const char *)callback_write_name, + (const char *)data_write, + &weechat_php_api_config_section_write_default_cb, + (const char *)callback_write_default_name, + (const char *)data_write_default, + &weechat_php_api_config_section_create_option_cb, + (const char *)callback_create_option_name, + (const char *)data_create_option, + &weechat_php_api_config_section_delete_option_cb, + (const char *)callback_delete_option_name, + (const char *)data_delete_option)); + + API_RETURN_STRING(result); } API_FUNC(config_search_section) @@ -1164,7 +1142,7 @@ API_FUNC(config_search_section) zend_string *z_config_file, *z_section_name; struct t_config_file *config_file; char *section_name; - struct t_config_section *retval; + const char *result; API_INIT_FUNC(1, "config_search_section", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1174,11 +1152,12 @@ API_FUNC(config_search_section) config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); section_name = ZSTR_VAL(z_section_name); - retval = weechat_config_search_section (config_file, - (const char *)section_name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_config_search_section (config_file, + (const char *)section_name)); + + API_RETURN_STRING(result); } static int @@ -1190,15 +1169,12 @@ weechat_php_api_config_option_check_value_cb (const void *pointer, int rc; void *func_argv[3]; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = value ? (char *)value : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -1210,13 +1186,10 @@ weechat_php_api_config_option_change_cb (const void *pointer, int *rc; void *func_argv[2]; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); weechat_php_cb (pointer, data, func_argv, "ss", WEECHAT_SCRIPT_EXEC_INT, &rc); - - if (func_argv[1]) - free (func_argv[1]); } static void @@ -1227,13 +1200,10 @@ weechat_php_api_config_option_delete_cb (const void *pointer, int rc; void *func_argv[2]; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); weechat_php_cb (pointer, data, func_argv, "ss", WEECHAT_SCRIPT_EXEC_INT, &rc); - - if (func_argv[1]) - free (func_argv[1]); } API_FUNC(config_new_option) @@ -1248,7 +1218,7 @@ API_FUNC(config_new_option) char *name, *type, *description, *string_values, *default_value, *value; char *data_check_value, *data_change, *data_delete; int min, max, null_value_allowed; - struct t_config_option *retval; + const char *result; API_INIT_FUNC(1, "config_new_option", API_RETURN_EMPTY); if (zend_parse_parameters ( @@ -1277,32 +1247,33 @@ API_FUNC(config_new_option) data_change = ZSTR_VAL(z_data_change); weechat_php_get_function_name (z_callback_delete, callback_delete_name); data_delete = ZSTR_VAL(z_data_delete); - retval = plugin_script_api_config_new_option ( - weechat_php_plugin, - php_current_script, - config_file, - section, - (const char *)name, - (const char *)type, - (const char *)description, - (const char *)string_values, - min, - max, - (const char *)default_value, - (const char *)value, - null_value_allowed, - &weechat_php_api_config_option_check_value_cb, - (const char *)callback_check_value_name, - (const char *)data_check_value, - &weechat_php_api_config_option_change_cb, - (const char *)callback_change_name, - (const char *)data_change, - &weechat_php_api_config_option_delete_cb, - (const char *)callback_delete_name, - (const char *)data_delete); - char *__retstr = API_PTR2STR(retval); - - API_RETURN_STRING_FREE(__retstr); + + result = API_PTR2STR( + plugin_script_api_config_new_option ( + weechat_php_plugin, + php_current_script, + config_file, + section, + (const char *)name, + (const char *)type, + (const char *)description, + (const char *)string_values, + min, + max, + (const char *)default_value, + (const char *)value, + null_value_allowed, + &weechat_php_api_config_option_check_value_cb, + (const char *)callback_check_value_name, + (const char *)data_check_value, + &weechat_php_api_config_option_change_cb, + (const char *)callback_change_name, + (const char *)data_change, + &weechat_php_api_config_option_delete_cb, + (const char *)callback_delete_name, + (const char *)data_delete)); + + API_RETURN_STRING(result); } API_FUNC(config_search_option) @@ -1311,7 +1282,7 @@ API_FUNC(config_search_option) struct t_config_file *config_file; struct t_config_section *section; char *option_name; - struct t_config_option *retval; + const char *result; API_INIT_FUNC(1, "config_search_option", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1322,27 +1293,28 @@ API_FUNC(config_search_option) config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); section = (struct t_config_section *)API_STR2PTR(ZSTR_VAL(z_section)); option_name = ZSTR_VAL(z_option_name); - retval = weechat_config_search_option (config_file, section, - (const char *)option_name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_config_search_option (config_file, section, + (const char *)option_name)); + + API_RETURN_STRING(result); } API_FUNC(config_string_to_boolean) { zend_string *z_text; char *text; - int retval; + int result; API_INIT_FUNC(1, "config_string_to_boolean", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_text) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); text = ZSTR_VAL(z_text); - retval = weechat_config_string_to_boolean ((const char *)text); + result = weechat_config_string_to_boolean ((const char *)text); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_option_reset) @@ -1350,7 +1322,7 @@ API_FUNC(config_option_reset) zend_string *z_option; zend_long z_run_callback; struct t_config_option *option; - int run_callback, retval; + int run_callback, result; API_INIT_FUNC(1, "config_option_reset", API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1359,9 +1331,9 @@ API_FUNC(config_option_reset) option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); run_callback = (int)z_run_callback; - retval = weechat_config_option_reset (option, run_callback); + result = weechat_config_option_reset (option, run_callback); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_option_set) @@ -1370,7 +1342,7 @@ API_FUNC(config_option_set) zend_long z_run_callback; struct t_config_option *option; char *value; - int run_callback, retval; + int run_callback, result; API_INIT_FUNC(1, "config_option_set", API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1381,10 +1353,10 @@ API_FUNC(config_option_set) option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); value = ZSTR_VAL(z_value); run_callback = (int)z_run_callback; - retval = weechat_config_option_set (option, (const char *)value, + result = weechat_config_option_set (option, (const char *)value, run_callback); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_option_set_null) @@ -1392,7 +1364,7 @@ API_FUNC(config_option_set_null) zend_string *z_option; zend_long z_run_callback; struct t_config_option *option; - int run_callback, retval; + int run_callback, result; API_INIT_FUNC(1, "config_option_set_null", API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1401,25 +1373,25 @@ API_FUNC(config_option_set_null) option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); run_callback = (int)z_run_callback; - retval = weechat_config_option_set_null (option, run_callback); + result = weechat_config_option_set_null (option, run_callback); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_option_unset) { zend_string *z_option; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_option_unset", API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_option_unset (option); + result = weechat_config_option_unset (option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_option_rename) @@ -1444,160 +1416,160 @@ API_FUNC(config_option_is_null) { zend_string *z_option; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_option_is_null", API_RETURN_INT(1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(1)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_option_is_null (option); + result = weechat_config_option_is_null (option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_option_default_is_null) { zend_string *z_option; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_option_default_is_null", API_RETURN_INT(1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(1)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_option_default_is_null (option); + result = weechat_config_option_default_is_null (option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_boolean) { zend_string *z_option; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_boolean", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_boolean (option); + result = weechat_config_boolean (option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_boolean_default) { zend_string *z_option; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_boolean_default", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_boolean_default (option); + result = weechat_config_boolean_default (option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_integer) { zend_string *z_option; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_integer", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_integer (option); + result = weechat_config_integer (option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_integer_default) { zend_string *z_option; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_integer_default", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_integer_default (option); + result = weechat_config_integer_default (option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_string) { zend_string *z_option; struct t_config_option *option; - const char *retval; + const char *result; API_INIT_FUNC(1, "config_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_string (option); + result = weechat_config_string (option); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(config_string_default) { zend_string *z_option; struct t_config_option *option; - const char *retval; + const char *result; API_INIT_FUNC(1, "config_string_default", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_string_default (option); + result = weechat_config_string_default (option); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(config_color) { zend_string *z_option; struct t_config_option *option; - const char *retval; + const char *result; API_INIT_FUNC(1, "config_color", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_color (option); + result = weechat_config_color (option); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(config_color_default) { zend_string *z_option; struct t_config_option *option; - const char *retval; + const char *result; API_INIT_FUNC(1, "config_color_default", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_color_default (option); + result = weechat_config_color_default (option); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(config_write_option) @@ -1605,7 +1577,7 @@ API_FUNC(config_write_option) zend_string *z_config_file, *z_option; struct t_config_file *config_file; struct t_config_option *option; - int retval; + int result; API_INIT_FUNC(1, "config_write_option", API_RETURN_ERROR); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1614,9 +1586,9 @@ API_FUNC(config_write_option) config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); - retval = weechat_config_write_option (config_file, option); + result = weechat_config_write_option (config_file, option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_write_line) @@ -1624,7 +1596,7 @@ API_FUNC(config_write_line) zend_string *z_config_file, *z_option_name, *z_value; struct t_config_file *config_file; char *option_name, *value; - int retval; + int result; API_INIT_FUNC(1, "config_write_line", API_RETURN_ERROR); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1635,18 +1607,18 @@ API_FUNC(config_write_line) config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); option_name = ZSTR_VAL(z_option_name); value = ZSTR_VAL(z_value); - retval = weechat_config_write_line (config_file, + result = weechat_config_write_line (config_file, (const char *)option_name, (const char *)value); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_write) { zend_string *z_config_file; struct t_config_file *config_file; - int retval; + int result; API_INIT_FUNC(1, "config_write", API_RETURN_INT(WEECHAT_CONFIG_WRITE_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1654,16 +1626,16 @@ API_FUNC(config_write) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_WRITE_ERROR)); config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); - retval = weechat_config_write (config_file); + result = weechat_config_write (config_file); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_read) { zend_string *z_config_file; struct t_config_file *config_file; - int retval; + int result; API_INIT_FUNC(1, "config_read", API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1671,16 +1643,16 @@ API_FUNC(config_read) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND)); config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); - retval = weechat_config_read (config_file); + result = weechat_config_read (config_file); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_reload) { zend_string *z_config_file; struct t_config_file *config_file; - int retval; + int result; API_INIT_FUNC(1, "config_reload", API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1688,9 +1660,9 @@ API_FUNC(config_reload) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND)); config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); - retval = weechat_config_reload (config_file); + result = weechat_config_reload (config_file); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_option_free) @@ -1760,7 +1732,7 @@ API_FUNC(config_get) { zend_string *z_option_name; char *option_name; - struct t_config_option *retval; + const char *result; API_INIT_FUNC(1, "config_get", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1768,53 +1740,53 @@ API_FUNC(config_get) API_WRONG_ARGS(API_RETURN_EMPTY); option_name = ZSTR_VAL(z_option_name); - retval = weechat_config_get ((const char *)option_name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_config_get ((const char *)option_name)); + + API_RETURN_STRING(result); } API_FUNC(config_get_plugin) { zend_string *z_option; char *option; - const char *retval; + const char *result; API_INIT_FUNC(1, "config_get_plugin", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); option = ZSTR_VAL(z_option); - retval = plugin_script_api_config_get_plugin (weechat_php_plugin, + result = plugin_script_api_config_get_plugin (weechat_php_plugin, php_current_script, (const char *)option); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(config_is_set_plugin) { zend_string *z_option; char *option; - int retval; + int result; API_INIT_FUNC(1, "config_is_set_plugin", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); option = ZSTR_VAL(z_option); - retval = plugin_script_api_config_is_set_plugin (weechat_php_plugin, + result = plugin_script_api_config_is_set_plugin (weechat_php_plugin, php_current_script, (const char *)option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_set_plugin) { zend_string *z_option, *z_value; char *option, *value; - int retval; + int result; API_INIT_FUNC(1, "config_set_plugin", API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1823,12 +1795,12 @@ API_FUNC(config_set_plugin) option = ZSTR_VAL(z_option); value = ZSTR_VAL(z_value); - retval = plugin_script_api_config_set_plugin (weechat_php_plugin, + result = plugin_script_api_config_set_plugin (weechat_php_plugin, php_current_script, (const char *)option, (const char *)value); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(config_set_desc_plugin) @@ -1855,18 +1827,18 @@ API_FUNC(config_unset_plugin) { zend_string *z_option; char *option; - int retval; + int result; API_INIT_FUNC(1, "config_unset_plugin", API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); option = ZSTR_VAL(z_option); - retval = plugin_script_api_config_unset_plugin (weechat_php_plugin, + result = plugin_script_api_config_unset_plugin (weechat_php_plugin, php_current_script, (const char *)option); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(key_bind) @@ -1875,7 +1847,7 @@ API_FUNC(key_bind) zval *z_keys; char *context; struct t_hashtable *keys; - int retval; + int result; API_INIT_FUNC(1, "key_bind", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -1887,15 +1859,15 @@ API_FUNC(key_bind) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); - retval = weechat_key_bind ((const char *)context, keys); + result = weechat_key_bind ((const char *)context, keys); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(key_unbind) { zend_string *z_context, *z_key; - int retval; + int result; char *context, *key; API_INIT_FUNC(1, "key_unbind", API_RETURN_INT(0)); @@ -1905,41 +1877,41 @@ API_FUNC(key_unbind) context = ZSTR_VAL(z_context); key = ZSTR_VAL(z_key); - retval = weechat_key_unbind ((const char *)context, (const char *)key); + result = weechat_key_unbind ((const char *)context, (const char *)key); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(prefix) { zend_string *z_prefix; char *prefix; - const char *retval; + const char *result; API_INIT_FUNC(0, "prefix", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_prefix) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); prefix = ZSTR_VAL(z_prefix); - retval = weechat_prefix ((const char *)prefix); + result = weechat_prefix ((const char *)prefix); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(color) { zend_string *z_color_name; char *color_name; - const char *retval; + const char *result; API_INIT_FUNC(0, "color", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_color_name) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); color_name = ZSTR_VAL(z_color_name); - retval = weechat_color ((const char *)color_name); + result = weechat_color ((const char *)color_name); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(print) @@ -2043,15 +2015,12 @@ weechat_php_api_hook_command_cb (const void *pointer, void *data, /* make C compiler happy */ (void) argv; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -2061,7 +2030,7 @@ API_FUNC(hook_command) zend_string *z_completion, *z_data; zval *z_callback; char *command, *description, *args, *args_description, *completion, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_command", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2077,19 +2046,21 @@ API_FUNC(hook_command) completion = ZSTR_VAL(z_completion); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_command (weechat_php_plugin, - php_current_script, - (const char *)command, - (const char *)description, - (const char *)args, - (const char *)args_description, - (const char *)completion, - &weechat_php_api_hook_command_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_command ( + weechat_php_plugin, + php_current_script, + (const char *)command, + (const char *)description, + (const char *)args, + (const char *)args_description, + (const char *)completion, + &weechat_php_api_hook_command_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2102,17 +2073,12 @@ weechat_php_api_hook_completion_cb (const void *pointer, void *data, void *func_argv[4]; func_argv[1] = completion_item ? (char *)completion_item : weechat_php_empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); weechat_php_cb (pointer, data, func_argv, "ssss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); - return rc; } @@ -2121,7 +2087,7 @@ API_FUNC(hook_completion) zend_string *z_completion, *z_description, *z_data; zval *z_callback; char *completion, *description, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2133,16 +2099,18 @@ API_FUNC(hook_completion) description = ZSTR_VAL(z_description); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_completion (weechat_php_plugin, - php_current_script, - (const char *)completion, - (const char *)description, - &weechat_php_api_hook_completion_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_completion ( + weechat_php_plugin, + php_current_script, + (const char *)completion, + (const char *)description, + &weechat_php_api_hook_completion_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(hook_completion_get_string) @@ -2150,7 +2118,7 @@ API_FUNC(hook_completion_get_string) zend_string *z_completion, *z_property; struct t_gui_completion *completion; char *property; - const char *retval; + const char *result; API_INIT_FUNC(1, "hook_completion_get_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2159,10 +2127,10 @@ API_FUNC(hook_completion_get_string) completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion)); property = ZSTR_VAL(z_property); - retval = weechat_hook_completion_get_string (completion, + result = weechat_hook_completion_get_string (completion, (const char *)property); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(hook_completion_list_add) @@ -2199,15 +2167,12 @@ weechat_php_api_hook_command_run_cb (const void *pointer, void *data, int rc; void *func_argv[3]; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = command ? (char *)command : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -2216,7 +2181,7 @@ API_FUNC(hook_command_run) zend_string *z_command, *z_data; zval *z_callback; char *command, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_command_run", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2227,15 +2192,17 @@ API_FUNC(hook_command_run) command = ZSTR_VAL(z_command); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_command_run (weechat_php_plugin, - php_current_script, - (const char *)command, - &weechat_php_api_hook_command_run_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_command_run ( + weechat_php_plugin, + php_current_script, + (const char *)command, + &weechat_php_api_hook_command_run_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2260,7 +2227,7 @@ API_FUNC(hook_timer) zend_string *z_data; int interval, align_second, max_calls; char *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2273,17 +2240,19 @@ API_FUNC(hook_timer) max_calls = (int)z_max_calls; weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_timer (weechat_php_plugin, - php_current_script, - interval, - align_second, - max_calls, - &weechat_php_api_hook_timer_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_timer ( + weechat_php_plugin, + php_current_script, + interval, + align_second, + max_calls, + &weechat_php_api_hook_timer_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2308,7 +2277,7 @@ API_FUNC(hook_fd) zend_string *z_data; int fd, flag_read, flag_write, flag_exception; char *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_fd", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2323,17 +2292,19 @@ API_FUNC(hook_fd) flag_exception = (int)z_flag_exception; weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_fd (weechat_php_plugin, - php_current_script, fd, - flag_read, - flag_write, - flag_exception, - &weechat_php_api_hook_fd_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_fd ( + weechat_php_plugin, + php_current_script, fd, + flag_read, + flag_write, + flag_exception, + &weechat_php_api_hook_fd_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2362,7 +2333,7 @@ API_FUNC(hook_process) zval *z_callback; char *command, *data; int timeout; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_process", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2374,16 +2345,18 @@ API_FUNC(hook_process) timeout = (int)z_timeout; weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_process (weechat_php_plugin, - php_current_script, - (const char *)command, - timeout, - &weechat_php_api_hook_process_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_process ( + weechat_php_plugin, + php_current_script, + (const char *)command, + timeout, + &weechat_php_api_hook_process_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2414,7 +2387,7 @@ API_FUNC(hook_process_hashtable) char *command, *data; struct t_hashtable *options; int timeout; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_process_hashtable", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2431,17 +2404,19 @@ API_FUNC(hook_process_hashtable) timeout = (int)z_timeout; weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_process_hashtable (weechat_php_plugin, - php_current_script, - (const char *)command, - options, - timeout, - &weechat_php_api_hook_process_hashtable_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_process_hashtable ( + weechat_php_plugin, + php_current_script, + (const char *)command, + options, + timeout, + &weechat_php_api_hook_process_hashtable_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2474,7 +2449,7 @@ API_FUNC(hook_connect) int port, ipv6, retry; void *gnutls_sess, *gnutls_cb; int gnutls_dhkey_size; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_connect", API_RETURN_EMPTY); if (zend_parse_parameters ( @@ -2496,24 +2471,26 @@ API_FUNC(hook_connect) local_hostname = ZSTR_VAL(z_local_hostname); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_connect (weechat_php_plugin, - php_current_script, - (const char *)proxy, - (const char *)address, - port, - ipv6, - retry, - gnutls_sess, - gnutls_cb, - gnutls_dhkey_size, - (const char *)gnutls_priorities, - (const char *)local_hostname, - &weechat_php_api_hook_connect_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - - API_RETURN_STRING_FREE(__retstr); + + result = API_PTR2STR( + plugin_script_api_hook_connect ( + weechat_php_plugin, + php_current_script, + (const char *)proxy, + (const char *)address, + port, + ipv6, + retry, + gnutls_sess, + gnutls_cb, + gnutls_dhkey_size, + (const char *)gnutls_priorities, + (const char *)local_hostname, + &weechat_php_api_hook_connect_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2526,7 +2503,7 @@ weechat_php_api_hook_print_cb (const void *pointer, void *data, int rc; void *func_argv[9]; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = &date; func_argv[3] = &tags_count; func_argv[4] = tags ? (char *)tags : weechat_php_empty_arg; @@ -2538,9 +2515,6 @@ weechat_php_api_hook_print_cb (const void *pointer, void *data, weechat_php_cb (pointer, data, func_argv, "ssiisiiss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -2552,7 +2526,7 @@ API_FUNC(hook_print) struct t_gui_buffer *buffer; char *tags, *message, *data; int strip_colors; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_print", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2567,17 +2541,19 @@ API_FUNC(hook_print) strip_colors = (int)z_strip_colors; weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_print (weechat_php_plugin, - php_current_script, buffer, - (const char *)tags, - (const char *)message, - strip_colors, - &weechat_php_api_hook_print_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_print ( + weechat_php_plugin, + php_current_script, buffer, + (const char *)tags, + (const char *)message, + strip_colors, + &weechat_php_api_hook_print_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static int @@ -2603,7 +2579,7 @@ API_FUNC(hook_signal) zend_string *z_signal, *z_data; zval *z_callback; char *signal, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_signal", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2614,15 +2590,17 @@ API_FUNC(hook_signal) signal = ZSTR_VAL(z_signal); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_signal (weechat_php_plugin, - php_current_script, - (const char *)signal, - &weechat_php_api_hook_signal_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_signal ( + weechat_php_plugin, + php_current_script, + (const char *)signal, + &weechat_php_api_hook_signal_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(hook_signal_send) @@ -2630,7 +2608,7 @@ API_FUNC(hook_signal_send) zend_string *z_signal, *z_type_data, *z_signal_data; char *signal, *type_data; void *signal_data; - int retval; + int result; API_INIT_FUNC(1, "hook_signal_send", API_RETURN_INT(WEECHAT_RC_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2641,10 +2619,10 @@ API_FUNC(hook_signal_send) signal = ZSTR_VAL(z_signal); type_data = ZSTR_VAL(z_type_data); signal_data = (void *)API_STR2PTR(ZSTR_VAL(z_signal_data)); - retval = weechat_hook_signal_send ((const char *)signal, + result = weechat_hook_signal_send ((const char *)signal, (const char *)type_data, signal_data); - API_RETURN_INT(retval); + API_RETURN_INT(result); } static int @@ -2668,8 +2646,8 @@ API_FUNC(hook_hsignal) { zend_string *z_signal, *z_data; zval *z_callback; - struct t_hook *retval; char *signal, *data; + const char *result; API_INIT_FUNC(1, "hook_hsignal", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2680,15 +2658,17 @@ API_FUNC(hook_hsignal) signal = ZSTR_VAL(z_signal); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_hsignal (weechat_php_plugin, - php_current_script, - (const char *)signal, - &weechat_php_api_hook_hsignal_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_hsignal ( + weechat_php_plugin, + php_current_script, + (const char *)signal, + &weechat_php_api_hook_hsignal_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(hook_hsignal_send) @@ -2697,7 +2677,7 @@ API_FUNC(hook_hsignal_send) zval *z_hashtable; char *signal; struct t_hashtable *hashtable; - int retval; + int result; API_INIT_FUNC(1, "hook_hsignal_send", API_RETURN_INT(WEECHAT_RC_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2710,9 +2690,9 @@ API_FUNC(hook_hsignal_send) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); - retval = weechat_hook_hsignal_send ((const char *)signal, hashtable); + result = weechat_hook_hsignal_send ((const char *)signal, hashtable); - API_RETURN_INT(retval); + API_RETURN_INT(result); } static int @@ -2736,7 +2716,7 @@ API_FUNC(hook_config) zend_string *z_option, *z_data; zval *z_callback; char *option, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_config", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2747,15 +2727,17 @@ API_FUNC(hook_config) option = ZSTR_VAL(z_option); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_config (weechat_php_plugin, - php_current_script, - (const char *)option, - &weechat_php_api_hook_config_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_config ( + weechat_php_plugin, + php_current_script, + (const char *)option, + &weechat_php_api_hook_config_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } static char * @@ -2782,7 +2764,7 @@ API_FUNC(hook_modifier) zend_string *z_modifier, *z_data; zval *z_callback; char *modifier, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_modifier", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2793,21 +2775,23 @@ API_FUNC(hook_modifier) modifier = ZSTR_VAL(z_modifier); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_modifier (weechat_php_plugin, - php_current_script, - (const char *)modifier, - &weechat_php_api_hook_modifier_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_modifier ( + weechat_php_plugin, + php_current_script, + (const char *)modifier, + &weechat_php_api_hook_modifier_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(hook_modifier_exec) { zend_string *z_modifier, *z_modifier_data, *z_string; - char *modifier, *modifier_data, *string, *retval; + char *modifier, *modifier_data, *string, *result; API_INIT_FUNC(1, "hook_modifier_exec", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2818,11 +2802,11 @@ API_FUNC(hook_modifier_exec) modifier = ZSTR_VAL(z_modifier); modifier_data = ZSTR_VAL(z_modifier_data); string = ZSTR_VAL(z_string); - retval = weechat_hook_modifier_exec ((const char *)modifier, + result = weechat_hook_modifier_exec ((const char *)modifier, (const char *)modifier_data, (const char *)string); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } static const char * @@ -2848,7 +2832,7 @@ API_FUNC(hook_info) zend_string *z_info_name, *z_description, *z_args_description, *z_data; zval *z_callback; char *info_name, *description, *args_description, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_info", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2862,17 +2846,19 @@ API_FUNC(hook_info) args_description = ZSTR_VAL(z_args_description); weechat_php_get_function_name (z_callback, callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_hook_info (weechat_php_plugin, - php_current_script, - (const char *)info_name, - (const char *)description, - (const char *)args_description, - &weechat_php_api_hook_info_cb, - (const char *)callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_info ( + weechat_php_plugin, + php_current_script, + (const char *)info_name, + (const char *)description, + (const char *)args_description, + &weechat_php_api_hook_info_cb, + (const char *)callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } struct t_hashtable * @@ -2899,7 +2885,7 @@ API_FUNC(hook_info_hashtable) zval *z_callback; char *info_name, *description, *args_description, *output_description; char *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2914,18 +2900,20 @@ API_FUNC(hook_info_hashtable) output_description = ZSTR_VAL(z_output_description); data = ZSTR_VAL(z_data); weechat_php_get_function_name (z_callback, callback_name); - retval = plugin_script_api_hook_info_hashtable (weechat_php_plugin, - php_current_script, - info_name, - description, - args_description, - output_description, - &weechat_php_api_hook_info_hashtable_cb, - callback_name, - data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_info_hashtable ( + weechat_php_plugin, + php_current_script, + info_name, + description, + args_description, + output_description, + &weechat_php_api_hook_info_hashtable_cb, + callback_name, + data)); + + API_RETURN_STRING(result); } struct t_infolist * @@ -2938,15 +2926,12 @@ weechat_php_api_hook_infolist_cb (const void *pointer, void *data, void *func_argv[4]; func_argv[1] = (info_name) ? (char *)info_name : weechat_php_empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "ssss", WEECHAT_SCRIPT_EXEC_STRING, &rc); - if (func_argv[2]) - free (func_argv[2]); - return rc; } @@ -2957,7 +2942,7 @@ API_FUNC(hook_infolist) zval *z_callback; char *infolist_name, *description, *pointer_description, *args_description; char *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_infolist", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -2972,18 +2957,20 @@ API_FUNC(hook_infolist) args_description = ZSTR_VAL(z_args_description); data = ZSTR_VAL(z_data); weechat_php_get_function_name (z_callback, callback_name); - retval = plugin_script_api_hook_infolist (weechat_php_plugin, - php_current_script, - infolist_name, - description, - pointer_description, - args_description, - &weechat_php_api_hook_infolist_cb, - callback_name, - data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_infolist ( + weechat_php_plugin, + php_current_script, + infolist_name, + description, + pointer_description, + args_description, + &weechat_php_api_hook_infolist_cb, + callback_name, + data)); + + API_RETURN_STRING(result); } struct t_hashtable * @@ -3006,7 +2993,7 @@ API_FUNC(hook_focus) zend_string *z_area, *z_data; zval *z_callback; char *area, *data; - struct t_hook *retval; + const char *result; API_INIT_FUNC(1, "hook_focus", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "SzS", &z_area, &z_callback, @@ -3016,15 +3003,17 @@ API_FUNC(hook_focus) area = ZSTR_VAL(z_area); data = ZSTR_VAL(z_data); weechat_php_get_function_name (z_callback, callback_name); - retval = plugin_script_api_hook_focus (weechat_php_plugin, - php_current_script, - area, - &weechat_php_api_hook_focus_cb, - callback_name, - data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_hook_focus ( + weechat_php_plugin, + php_current_script, + area, + &weechat_php_api_hook_focus_cb, + callback_name, + data)); + + API_RETURN_STRING(result); } API_FUNC(hook_set) @@ -3084,15 +3073,12 @@ weechat_php_api_buffer_input_data_cb (const void *pointer, void *data, int rc; void *func_argv[3]; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = input_data ? (char *)input_data : weechat_php_empty_arg; weechat_php_cb (pointer, data, func_argv, "sss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -3103,14 +3089,11 @@ weechat_php_api_buffer_close_cb (const void *pointer, void *data, int rc; void *func_argv[2]; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); weechat_php_cb (pointer, data, func_argv, "ss", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - return rc; } @@ -3119,7 +3102,7 @@ API_FUNC(buffer_new) zend_string *z_name, *z_data_input, *z_data_close; zval *z_input_callback, *z_close_callback; char *name, *data_input, *data_close; - struct t_gui_buffer *retval; + const char *result; API_INIT_FUNC(1, "buffer_new", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3133,25 +3116,27 @@ API_FUNC(buffer_new) data_input = ZSTR_VAL(z_data_input); weechat_php_get_function_name (z_close_callback, close_callback_name); data_close = ZSTR_VAL(z_data_close); - retval = plugin_script_api_buffer_new (weechat_php_plugin, - php_current_script, - (const char *)name, - &weechat_php_api_buffer_input_data_cb, - (const char *)input_callback_name, - (const char *)data_input, - &weechat_php_api_buffer_close_cb, - (const char *)close_callback_name, - (const char *)data_close); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_buffer_new ( + weechat_php_plugin, + php_current_script, + (const char *)name, + &weechat_php_api_buffer_input_data_cb, + (const char *)input_callback_name, + (const char *)data_input, + &weechat_php_api_buffer_close_cb, + (const char *)close_callback_name, + (const char *)data_close)); + + API_RETURN_STRING(result); } API_FUNC(buffer_search) { zend_string *z_plugin, *z_name; char *plugin, *name; - struct t_gui_buffer *retval; + const char *result; API_INIT_FUNC(1, "buffer_search", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3160,38 +3145,37 @@ API_FUNC(buffer_search) plugin = ZSTR_VAL(z_plugin); name = ZSTR_VAL(z_name); - retval = weechat_buffer_search ((const char *)plugin, (const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_buffer_search ((const char *)plugin, (const char *)name)); + + API_RETURN_STRING(result); } API_FUNC(buffer_search_main) { - struct t_gui_buffer *retval; + const char *result; API_INIT_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); if (zend_parse_parameters_none () == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); - retval = weechat_buffer_search_main (); - char *__retstr = API_PTR2STR(retval); + result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(__retstr); + API_RETURN_STRING(result); } API_FUNC(current_buffer) { - struct t_gui_buffer *retval; + const char *result; API_INIT_FUNC(1, "current_buffer", API_RETURN_EMPTY); if (zend_parse_parameters_none () == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); - retval = weechat_current_buffer (); - char *__retstr = API_PTR2STR(retval); + result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(__retstr); + API_RETURN_STRING(result); } API_FUNC(buffer_clear) @@ -3267,7 +3251,7 @@ API_FUNC(buffer_get_integer) zend_string *z_buffer, *z_property; struct t_gui_buffer *buffer; char *property; - int retval; + int result; API_INIT_FUNC(1, "buffer_get_integer", API_RETURN_INT(-1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3276,15 +3260,15 @@ API_FUNC(buffer_get_integer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); property = ZSTR_VAL(z_property); - retval = weechat_buffer_get_integer (buffer, (const char *)property); + result = weechat_buffer_get_integer (buffer, (const char *)property); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(buffer_get_string) { zend_string *z_buffer, *z_property; - const char *retval; + const char *result; struct t_gui_buffer *buffer; char *property; @@ -3295,17 +3279,17 @@ API_FUNC(buffer_get_string) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); property = ZSTR_VAL(z_property); - retval = weechat_buffer_get_string (buffer, (const char *)property); + result = weechat_buffer_get_string (buffer, (const char *)property); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(buffer_get_pointer) { zend_string *z_buffer, *z_property; - void *retval; struct t_gui_buffer *buffer; char *property; + const char *result; API_INIT_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3314,10 +3298,11 @@ API_FUNC(buffer_get_pointer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); property = ZSTR_VAL(z_property); - retval = weechat_buffer_get_pointer (buffer, (const char *)property); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_buffer_get_pointer (buffer, (const char *)property)); + + API_RETURN_STRING(result); } API_FUNC(buffer_set) @@ -3344,7 +3329,7 @@ API_FUNC(buffer_string_replace_local_var) { zend_string *z_buffer, *z_string; struct t_gui_buffer *buffer; - char *string, *retval; + char *string, *result; API_INIT_FUNC(1, "buffer_string_replace_local_var", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3353,10 +3338,10 @@ API_FUNC(buffer_string_replace_local_var) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); string = ZSTR_VAL(z_string); - retval = weechat_buffer_string_replace_local_var (buffer, + result = weechat_buffer_string_replace_local_var (buffer, (const char *)string); - API_RETURN_STRING_FREE(retval); + API_RETURN_STRING_FREE(result); } API_FUNC(buffer_match_list) @@ -3364,7 +3349,7 @@ API_FUNC(buffer_match_list) zend_string *z_buffer, *z_string; struct t_gui_buffer *buffer; char *string; - int retval; + int result; API_INIT_FUNC(1, "buffer_match_list", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3373,40 +3358,39 @@ API_FUNC(buffer_match_list) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); string = ZSTR_VAL(z_string); - retval = weechat_buffer_match_list (buffer, (const char *)string); + result = weechat_buffer_match_list (buffer, (const char *)string); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(current_window) { - struct t_gui_window *retval; + const char *result; API_INIT_FUNC(1, "current_window", API_RETURN_EMPTY); if (zend_parse_parameters_none () == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); - retval = weechat_current_window (); - char *__retstr = API_PTR2STR(retval); + result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(__retstr); + API_RETURN_STRING(result); } API_FUNC(window_search_with_buffer) { zend_string *z_buffer; struct t_gui_buffer *buffer; - struct t_gui_window *retval; + const char *result; API_INIT_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_buffer) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); - retval = weechat_window_search_with_buffer (buffer); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_window_search_with_buffer (buffer)); + + API_RETURN_STRING(result); } API_FUNC(window_get_integer) @@ -3414,7 +3398,7 @@ API_FUNC(window_get_integer) zend_string *z_window, *z_property; struct t_gui_window *window; char *property; - int retval; + int result; API_INIT_FUNC(1, "window_get_integer", API_RETURN_INT(-1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3423,9 +3407,9 @@ API_FUNC(window_get_integer) window = (struct t_gui_window *)API_STR2PTR(ZSTR_VAL(z_window)); property = ZSTR_VAL(z_property); - retval = weechat_window_get_integer (window, (const char *)property); + result = weechat_window_get_integer (window, (const char *)property); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(window_get_string) @@ -3433,7 +3417,7 @@ API_FUNC(window_get_string) zend_string *z_window, *z_property; struct t_gui_window *window; char *property; - const char *retval; + const char *result; API_INIT_FUNC(1, "window_get_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3442,9 +3426,9 @@ API_FUNC(window_get_string) window = (struct t_gui_window *)API_STR2PTR(ZSTR_VAL(z_window)); property = ZSTR_VAL(z_property); - retval = weechat_window_get_string (window, (const char *)property); + result = weechat_window_get_string (window, (const char *)property); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(window_get_pointer) @@ -3452,7 +3436,7 @@ API_FUNC(window_get_pointer) zend_string *z_window, *z_property; struct t_gui_window *window; char *property; - void *retval; + const char *result; API_INIT_FUNC(1, "window_get_pointer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3461,10 +3445,11 @@ API_FUNC(window_get_pointer) window = (struct t_gui_window *)API_STR2PTR(ZSTR_VAL(z_window)); property = ZSTR_VAL(z_property); - retval = weechat_window_get_pointer (window, (const char *)property); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_window_get_pointer (window, (const char *)property)); + + API_RETURN_STRING(result); } API_FUNC(window_set_title) @@ -3487,9 +3472,10 @@ API_FUNC(nicklist_add_group) zend_string *z_buffer, *z_parent_group, *z_name, *z_color; zend_long z_visible; struct t_gui_buffer *buffer; - struct t_gui_nick_group *parent_group, *retval; + struct t_gui_nick_group *parent_group; char *name, *color; int visible; + const char *result; API_INIT_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3502,23 +3488,23 @@ API_FUNC(nicklist_add_group) name = ZSTR_VAL(z_name); color = ZSTR_VAL(z_color); visible = (int)z_visible; - retval = weechat_nicklist_add_group (buffer, - parent_group, - (const char *)name, - (const char *)color, - visible); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_nicklist_add_group (buffer, + parent_group, + (const char *)name, + (const char *)color, + visible)); + + API_RETURN_STRING(result); } API_FUNC(nicklist_search_group) { zend_string *z_buffer, *z_from_group, *z_name; - struct t_gui_nick_group *retval; struct t_gui_buffer *buffer; struct t_gui_nick_group *from_group; char *name; + const char *result; API_INIT_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3529,12 +3515,12 @@ API_FUNC(nicklist_search_group) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); from_group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_from_group)); name = ZSTR_VAL(z_name); - retval = weechat_nicklist_search_group (buffer, - from_group, - (const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_nicklist_search_group (buffer, + from_group, + (const char *)name)); + + API_RETURN_STRING(result); } API_FUNC(nicklist_add_nick) @@ -3546,7 +3532,7 @@ API_FUNC(nicklist_add_nick) struct t_gui_nick_group *group; char *name, *color, *prefix, *prefix_color; int visible; - struct t_gui_nick *retval; + const char *result; API_INIT_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3562,16 +3548,18 @@ API_FUNC(nicklist_add_nick) prefix = ZSTR_VAL(z_prefix); prefix_color = ZSTR_VAL(z_prefix_color); visible = (int)z_visible; - retval = weechat_nicklist_add_nick (buffer, - group, - (const char *)name, - (const char *)color, - (const char *)prefix, - (const char *)prefix_color, - visible); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_nicklist_add_nick ( + buffer, + group, + (const char *)name, + (const char *)color, + (const char *)prefix, + (const char *)prefix_color, + visible)); + + API_RETURN_STRING(result); } API_FUNC(nicklist_search_nick) @@ -3579,8 +3567,8 @@ API_FUNC(nicklist_search_nick) zend_string *z_buffer, *z_from_group, *z_name; struct t_gui_buffer *buffer; struct t_gui_nick_group *from_group; - struct t_gui_nick *retval; char *name; + const char *result; API_INIT_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3591,12 +3579,12 @@ API_FUNC(nicklist_search_nick) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); from_group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_from_group)); name = ZSTR_VAL(z_name); - retval = weechat_nicklist_search_nick (buffer, - from_group, - (const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_nicklist_search_nick (buffer, + from_group, + (const char *)name)); + + API_RETURN_STRING(result); } API_FUNC(nicklist_remove_group) @@ -3656,7 +3644,7 @@ API_FUNC(nicklist_group_get_integer) struct t_gui_buffer *buffer; struct t_gui_nick_group *group; char *property; - int retval; + int result; API_INIT_FUNC(1, "nicklist_group_get_integer", API_RETURN_INT(-1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3667,11 +3655,11 @@ API_FUNC(nicklist_group_get_integer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group)); property = ZSTR_VAL(z_property); - retval = weechat_nicklist_group_get_integer (buffer, + result = weechat_nicklist_group_get_integer (buffer, group, (const char *)property); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(nicklist_group_get_string) @@ -3680,7 +3668,7 @@ API_FUNC(nicklist_group_get_string) struct t_gui_buffer *buffer; struct t_gui_nick_group *group; char *property; - const char *retval; + const char *result; API_INIT_FUNC(1, "nicklist_group_get_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3691,11 +3679,11 @@ API_FUNC(nicklist_group_get_string) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group)); property = ZSTR_VAL(z_property); - retval = weechat_nicklist_group_get_string (buffer, + result = weechat_nicklist_group_get_string (buffer, group, (const char *)property); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(nicklist_group_get_pointer) @@ -3704,7 +3692,7 @@ API_FUNC(nicklist_group_get_pointer) struct t_gui_buffer *buffer; struct t_gui_nick_group *group; char *property; - void *retval; + const char *result; API_INIT_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3715,12 +3703,13 @@ API_FUNC(nicklist_group_get_pointer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group)); property = ZSTR_VAL(z_property); - retval = weechat_nicklist_group_get_pointer (buffer, - group, - (const char *)property); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_nicklist_group_get_pointer (buffer, + group, + (const char *)property)); + + API_RETURN_STRING(result); } API_FUNC(nicklist_group_set) @@ -3754,7 +3743,7 @@ API_FUNC(nicklist_nick_get_integer) struct t_gui_buffer *buffer; struct t_gui_nick *nick; char *property; - int retval; + int result; API_INIT_FUNC(1, "nicklist_nick_get_integer", API_RETURN_INT(-1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3765,11 +3754,11 @@ API_FUNC(nicklist_nick_get_integer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick)); property = ZSTR_VAL(z_property); - retval = weechat_nicklist_nick_get_integer (buffer, + result = weechat_nicklist_nick_get_integer (buffer, nick, (const char *)property); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(nicklist_nick_get_string) @@ -3778,7 +3767,7 @@ API_FUNC(nicklist_nick_get_string) struct t_gui_buffer *buffer; struct t_gui_nick *nick; char *property; - const char *retval; + const char *result; API_INIT_FUNC(1, "nicklist_nick_get_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3789,11 +3778,11 @@ API_FUNC(nicklist_nick_get_string) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick)); property = ZSTR_VAL(z_property); - retval = weechat_nicklist_nick_get_string (buffer, + result = weechat_nicklist_nick_get_string (buffer, nick, (const char *)property); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(nicklist_nick_get_pointer) @@ -3802,7 +3791,7 @@ API_FUNC(nicklist_nick_get_pointer) struct t_gui_buffer *buffer; struct t_gui_nick *nick; char *property; - void *retval; + const char *result; API_INIT_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3813,12 +3802,13 @@ API_FUNC(nicklist_nick_get_pointer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick)); property = ZSTR_VAL(z_property); - retval = weechat_nicklist_nick_get_pointer (buffer, - nick, - (const char *)property); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_nicklist_nick_get_pointer (buffer, + nick, + (const char *)property)); + + API_RETURN_STRING(result); } API_FUNC(nicklist_nick_set) @@ -3849,18 +3839,18 @@ API_FUNC(nicklist_nick_set) API_FUNC(bar_item_search) { zend_string *z_name; - struct t_gui_bar_item *retval; char *name; + const char *result; API_INIT_FUNC(1, "bar_item_search", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_name) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); name = ZSTR_VAL(z_name); - retval = weechat_bar_item_search ((const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_bar_item_search ((const char *)name)); + + API_RETURN_STRING(result); } static char * @@ -3873,21 +3863,14 @@ weechat_php_api_bar_item_new_build_cb (const void *pointer, void *data, char *rc; void *func_argv[5]; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = extra_info; weechat_php_cb (pointer, data, func_argv, "ssssh", WEECHAT_SCRIPT_EXEC_STRING, &rc); - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); - return rc; } @@ -3895,8 +3878,8 @@ API_FUNC(bar_item_new) { zend_string *z_name, *z_data; zval *z_build_callback; - struct t_gui_bar_item *retval; char *name, *data; + const char *result; API_INIT_FUNC(1, "bar_item_new", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -3907,15 +3890,17 @@ API_FUNC(bar_item_new) name = ZSTR_VAL(z_name); weechat_php_get_function_name (z_build_callback, build_callback_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_bar_item_new (weechat_php_plugin, - php_current_script, - (const char *)name, - &weechat_php_api_bar_item_new_build_cb, - (const char *)build_callback_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_bar_item_new ( + weechat_php_plugin, + php_current_script, + (const char *)name, + &weechat_php_api_bar_item_new_build_cb, + (const char *)build_callback_name, + (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(bar_item_update) @@ -3951,18 +3936,18 @@ API_FUNC(bar_item_remove) API_FUNC(bar_search) { zend_string *z_name; - struct t_gui_bar *retval; char *name; + const char *result; API_INIT_FUNC(1, "bar_search", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_name) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); name = ZSTR_VAL(z_name); - retval = weechat_bar_search ((const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_bar_search ((const char *)name)); + + API_RETURN_STRING(result); } API_FUNC(bar_new) @@ -3974,7 +3959,7 @@ API_FUNC(bar_new) char *name, *hidden, *priority, *type, *condition, *position; char *filling_top_bottom, *filling_left_right, *size, *size_max, *color_fg; char *color_delim, *color_bg, *separator, *items; - struct t_gui_bar *retval; + const char *result; API_INIT_FUNC(1, "bar_new", API_RETURN_EMPTY); if (zend_parse_parameters ( @@ -4000,25 +3985,26 @@ API_FUNC(bar_new) color_bg = ZSTR_VAL(z_color_bg); separator = ZSTR_VAL(z_separator); items = ZSTR_VAL(z_items); - retval = weechat_bar_new ( - (const char *)name, - (const char *)hidden, - (const char *)priority, - (const char *)type, - (const char *)condition, - (const char *)position, - (const char *)filling_top_bottom, - (const char *)filling_left_right, - (const char *)size, - (const char *)size_max, - (const char *)color_fg, - (const char *)color_delim, - (const char *)color_bg, - (const char *)separator, - (const char *)items); - char *__retstr = API_PTR2STR(retval); - - API_RETURN_STRING_FREE(__retstr); + + result = API_PTR2STR( + weechat_bar_new ( + (const char *)name, + (const char *)hidden, + (const char *)priority, + (const char *)type, + (const char *)condition, + (const char *)position, + (const char *)filling_top_bottom, + (const char *)filling_left_right, + (const char *)size, + (const char *)size_max, + (const char *)color_fg, + (const char *)color_delim, + (const char *)color_bg, + (const char *)separator, + (const char *)items)); + + API_RETURN_STRING(result); } API_FUNC(bar_set) @@ -4026,7 +4012,7 @@ API_FUNC(bar_set) zend_string *z_bar, *z_property, *z_value; struct t_gui_bar *bar; char *property, *value; - int retval; + int result; API_INIT_FUNC(1, "bar_set", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4036,9 +4022,9 @@ API_FUNC(bar_set) bar = (struct t_gui_bar *)API_STR2PTR(ZSTR_VAL(z_bar)); property = ZSTR_VAL(z_property); value = ZSTR_VAL(z_value); - retval = weechat_bar_set (bar, (const char *)property, (const char *)value); + result = weechat_bar_set (bar, (const char *)property, (const char *)value); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(bar_update) @@ -4076,7 +4062,7 @@ API_FUNC(command) zend_string *z_buffer, *z_command; struct t_gui_buffer *buffer; char *command; - int retval; + int result; API_INIT_FUNC(1, "command", API_RETURN_INT(WEECHAT_RC_ERROR)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4085,19 +4071,19 @@ API_FUNC(command) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); command = ZSTR_VAL(z_command); - retval = plugin_script_api_command (weechat_php_plugin, + result = plugin_script_api_command (weechat_php_plugin, php_current_script, buffer, (const char *)command); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(info_get) { zend_string *z_info_name, *z_arguments; char *info_name, *arguments; - const char *retval; + const char *result; API_INIT_FUNC(1, "info_get", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4106,10 +4092,10 @@ API_FUNC(info_get) info_name = ZSTR_VAL(z_info_name); arguments = ZSTR_VAL(z_arguments); - retval = weechat_info_get ((const char *)info_name, + result = weechat_info_get ((const char *)info_name, (const char *)arguments); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(info_get_hashtable) @@ -4117,7 +4103,7 @@ API_FUNC(info_get_hashtable) zend_string *z_info_name; zval *z_hashtable; char *info_name; - struct t_hashtable *hashtable, *retval; + struct t_hashtable *hashtable, *result; API_INIT_FUNC(1, "info_get_hashtable", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4130,40 +4116,39 @@ API_FUNC(info_get_hashtable) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); - retval = weechat_info_get_hashtable ((const char *)info_name, hashtable); + result = weechat_info_get_hashtable ((const char *)info_name, hashtable); - weechat_php_hashtable_to_array (retval, return_value); + weechat_php_hashtable_to_array (result, return_value); } API_FUNC(infolist_new) { - struct t_infolist *retval; + const char *result; API_INIT_FUNC(1, "infolist_new", API_RETURN_EMPTY); if (zend_parse_parameters_none () == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); - retval = weechat_infolist_new (); - char *__retstr = API_PTR2STR(retval); + result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(__retstr); + API_RETURN_STRING(result); } API_FUNC(infolist_new_item) { zend_string *z_infolist; struct t_infolist *infolist; - struct t_infolist_item *retval; + const char *result; API_INIT_FUNC(1, "infolist_new_item", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_infolist) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); - retval = weechat_infolist_new_item (infolist); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_infolist_new_item (infolist)); + + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_integer) @@ -4173,7 +4158,7 @@ API_FUNC(infolist_new_var_integer) struct t_infolist_item *item; char *name; int value; - struct t_infolist_var *retval; + const char *result; API_INIT_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4183,12 +4168,12 @@ API_FUNC(infolist_new_var_integer) item = (struct t_infolist_item *)API_STR2PTR(ZSTR_VAL(z_item)); name = ZSTR_VAL(z_name); value = (int)z_value; - retval = weechat_infolist_new_var_integer (item, - (const char *)name, - value); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_infolist_new_var_integer (item, + (const char *)name, + value)); + + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_string) @@ -4196,7 +4181,7 @@ API_FUNC(infolist_new_var_string) zend_string *z_item, *z_name, *z_value; struct t_infolist_item *item; char *name, *value; - struct t_infolist_var *retval; + const char *result; API_INIT_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4206,12 +4191,13 @@ API_FUNC(infolist_new_var_string) item = (struct t_infolist_item *)API_STR2PTR(ZSTR_VAL(z_item)); name = ZSTR_VAL(z_name); value = ZSTR_VAL(z_value); - retval = weechat_infolist_new_var_string (item, - (const char *)name, - (const char *)value); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_infolist_new_var_string (item, + (const char *)name, + (const char *)value)); + + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_pointer) @@ -4220,7 +4206,7 @@ API_FUNC(infolist_new_var_pointer) struct t_infolist_item *item; char *name; void *pointer; - struct t_infolist_var *retval; + const char *result; API_INIT_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4230,12 +4216,13 @@ API_FUNC(infolist_new_var_pointer) item = (struct t_infolist_item *)API_STR2PTR(ZSTR_VAL(z_item)); name = ZSTR_VAL(z_name); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); - retval = weechat_infolist_new_var_pointer (item, - (const char *)name, - pointer); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_infolist_new_var_pointer (item, + (const char *)name, + pointer)); + + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_time) @@ -4245,7 +4232,7 @@ API_FUNC(infolist_new_var_time) struct t_infolist_item *item; char *name; time_t time; - struct t_infolist_var *retval; + const char *result; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4255,10 +4242,11 @@ API_FUNC(infolist_new_var_time) item = (struct t_infolist_item *)API_STR2PTR(ZSTR_VAL(z_item)); name = ZSTR_VAL(z_name); time = (time_t)z_time; - retval = weechat_infolist_new_var_time (item, (const char *)name, time); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_infolist_new_var_time (item, (const char *)name, time)); + + API_RETURN_STRING(result); } API_FUNC(infolist_search_var) @@ -4266,7 +4254,7 @@ API_FUNC(infolist_search_var) zend_string *z_infolist, *z_name; struct t_infolist *infolist; char *name; - struct t_infolist_var *retval; + const char *result; API_INIT_FUNC(1, "infolist_search_var", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4275,18 +4263,19 @@ API_FUNC(infolist_search_var) infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); name = ZSTR_VAL(z_name); - retval = weechat_infolist_search_var (infolist, (const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_infolist_search_var (infolist, (const char *)name)); + + API_RETURN_STRING(result); } API_FUNC(infolist_get) { zend_string *z_infolist_name, *z_pointer, *z_arguments; - struct t_infolist *retval; char *infolist_name, *arguments; void *pointer; + const char *result; API_INIT_FUNC(1, "infolist_get", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4297,44 +4286,45 @@ API_FUNC(infolist_get) infolist_name = ZSTR_VAL(z_infolist_name); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); arguments = ZSTR_VAL(z_arguments); - retval = weechat_infolist_get ((const char *)infolist_name, - pointer, - (const char *)arguments); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_infolist_get ((const char *)infolist_name, + pointer, + (const char *)arguments)); + + API_RETURN_STRING(result); } API_FUNC(infolist_next) { zend_string *z_infolist; struct t_infolist *infolist; - int retval; + int result; API_INIT_FUNC(1, "infolist_next", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_infolist) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); - retval = weechat_infolist_next (infolist); + result = weechat_infolist_next (infolist); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(infolist_prev) { zend_string *z_infolist; struct t_infolist *infolist; - int retval; + int result; API_INIT_FUNC(1, "infolist_prev", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_infolist) == FAILURE) API_WRONG_ARGS(API_RETURN_INT(0)); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); - retval = weechat_infolist_prev (infolist); + result = weechat_infolist_prev (infolist); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(infolist_reset_item_cursor) @@ -4356,16 +4346,16 @@ API_FUNC(infolist_fields) { zend_string *z_infolist; struct t_infolist *infolist; - const char *retval; + const char *result; API_INIT_FUNC(1, "infolist_fields", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_infolist) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); - retval = weechat_infolist_fields (infolist); + result = weechat_infolist_fields (infolist); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(infolist_integer) @@ -4373,7 +4363,7 @@ API_FUNC(infolist_integer) zend_string *z_infolist, *z_var; struct t_infolist *infolist; char *var; - int retval; + int result; API_INIT_FUNC(1, "infolist_integer", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4382,9 +4372,9 @@ API_FUNC(infolist_integer) infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); var = ZSTR_VAL(z_var); - retval = weechat_infolist_integer (infolist, (const char *)var); + result = weechat_infolist_integer (infolist, (const char *)var); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(infolist_string) @@ -4392,7 +4382,7 @@ API_FUNC(infolist_string) zend_string *z_infolist, *z_var; struct t_infolist *infolist; char *var; - const char *retval; + const char *result; API_INIT_FUNC(1, "infolist_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4401,9 +4391,9 @@ API_FUNC(infolist_string) infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); var = ZSTR_VAL(z_var); - retval = weechat_infolist_string (infolist, (const char *)var); + result = weechat_infolist_string (infolist, (const char *)var); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(infolist_pointer) @@ -4411,7 +4401,7 @@ API_FUNC(infolist_pointer) zend_string *z_infolist, *z_var; struct t_infolist *infolist; char *var; - void *retval; + const char *result; API_INIT_FUNC(1, "infolist_pointer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4420,10 +4410,11 @@ API_FUNC(infolist_pointer) infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); var = ZSTR_VAL(z_var); - retval = weechat_infolist_pointer (infolist, (const char *)var); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_infolist_pointer (infolist, (const char *)var)); + + API_RETURN_STRING(result); } API_FUNC(infolist_time) @@ -4431,7 +4422,7 @@ API_FUNC(infolist_time) zend_string *z_infolist, *z_var; struct t_infolist *infolist; char *var; - time_t retval; + time_t result; API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4440,9 +4431,9 @@ API_FUNC(infolist_time) infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); var = ZSTR_VAL(z_var); - retval = weechat_infolist_time (infolist, (const char *)var); + result = weechat_infolist_time (infolist, (const char *)var); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(infolist_free) @@ -4464,17 +4455,17 @@ API_FUNC(hdata_get) { zend_string *z_hdata_name; char *hdata_name; - struct t_hdata *retval; + const char *result; API_INIT_FUNC(1, "hdata_get", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_hdata_name) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); hdata_name = ZSTR_VAL(z_hdata_name); - retval = weechat_hdata_get ((const char *)hdata_name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_hdata_get ((const char *)hdata_name)); + + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_offset) @@ -4482,7 +4473,7 @@ API_FUNC(hdata_get_var_offset) zend_string *z_hdata, *z_name; struct t_hdata *hdata; char *name; - int retval; + int result; API_INIT_FUNC(1, "hdata_get_var_offset", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4491,9 +4482,9 @@ API_FUNC(hdata_get_var_offset) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_get_var_offset (hdata, (const char *)name); + result = weechat_hdata_get_var_offset (hdata, (const char *)name); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(hdata_get_var_type_string) @@ -4501,7 +4492,7 @@ API_FUNC(hdata_get_var_type_string) zend_string *z_hdata, *z_name; struct t_hdata *hdata; char *name; - const char *retval; + const char *result; API_INIT_FUNC(1, "hdata_get_var_type_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4510,9 +4501,9 @@ API_FUNC(hdata_get_var_type_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_get_var_type_string (hdata, (const char *)name); + result = weechat_hdata_get_var_type_string (hdata, (const char *)name); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_array_size) @@ -4521,7 +4512,7 @@ API_FUNC(hdata_get_var_array_size) struct t_hdata *hdata; void *pointer; char *name; - int retval; + int result; API_INIT_FUNC(1, "hdata_get_var_array_size", API_RETURN_INT(-1)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4531,11 +4522,11 @@ API_FUNC(hdata_get_var_array_size) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_get_var_array_size (hdata, + result = weechat_hdata_get_var_array_size (hdata, pointer, (const char *)name); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(hdata_get_var_array_size_string) @@ -4544,7 +4535,7 @@ API_FUNC(hdata_get_var_array_size_string) struct t_hdata *hdata; void *pointer; char *name; - const char *retval; + const char *result; API_INIT_FUNC(1, "hdata_get_var_array_size_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4554,11 +4545,11 @@ API_FUNC(hdata_get_var_array_size_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_get_var_array_size_string (hdata, + result = weechat_hdata_get_var_array_size_string (hdata, pointer, (const char *)name); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_hdata) @@ -4566,7 +4557,7 @@ API_FUNC(hdata_get_var_hdata) zend_string *z_hdata, *z_name; struct t_hdata *hdata; char *name; - const char *retval; + const char *result; API_INIT_FUNC(1, "hdata_get_var_hdata", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4575,9 +4566,9 @@ API_FUNC(hdata_get_var_hdata) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_get_var_hdata (hdata, (const char *)name); + result = weechat_hdata_get_var_hdata (hdata, (const char *)name); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(hdata_get_list) @@ -4585,7 +4576,7 @@ API_FUNC(hdata_get_list) zend_string *z_hdata, *z_name; struct t_hdata *hdata; char *name; - void *retval; + const char *result; API_INIT_FUNC(1, "hdata_get_list", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4594,10 +4585,11 @@ API_FUNC(hdata_get_list) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_get_list (hdata, (const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_hdata_get_list (hdata, (const char *)name)); + + API_RETURN_STRING(result); } API_FUNC(hdata_check_pointer) @@ -4605,7 +4597,7 @@ API_FUNC(hdata_check_pointer) zend_string *z_hdata, *z_list, *z_pointer; struct t_hdata *hdata; void *list, *pointer; - int retval; + int result; API_INIT_FUNC(1, "hdata_check_pointer", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4615,9 +4607,9 @@ API_FUNC(hdata_check_pointer) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); list = (void *)API_STR2PTR(ZSTR_VAL(z_list)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); - retval = weechat_hdata_check_pointer (hdata, list, pointer); + result = weechat_hdata_check_pointer (hdata, list, pointer); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(hdata_move) @@ -4627,7 +4619,7 @@ API_FUNC(hdata_move) struct t_hdata *hdata; void *pointer; int count; - void *retval; + const char *result; API_INIT_FUNC(1, "hdata_move", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4637,10 +4629,10 @@ API_FUNC(hdata_move) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); count = (int)z_count; - retval = weechat_hdata_move (hdata, pointer, count); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR(weechat_hdata_move (hdata, pointer, count)); + + API_RETURN_STRING(result); } API_FUNC(hdata_search) @@ -4651,7 +4643,7 @@ API_FUNC(hdata_search) void *pointer; char *search; int move; - void *retval; + const char *result; API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4663,10 +4655,11 @@ API_FUNC(hdata_search) pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); search = ZSTR_VAL(z_search); move = (int)z_move; - retval = weechat_hdata_search (hdata, pointer, (const char *)search, move); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_hdata_search (hdata, pointer, (const char *)search, move)); + + API_RETURN_STRING(result); } API_FUNC(hdata_char) @@ -4674,7 +4667,7 @@ API_FUNC(hdata_char) zend_string *z_hdata, *z_pointer, *z_name; struct t_hdata *hdata; void *pointer; - char *name, retval; + char *name, result; API_INIT_FUNC(1, "hdata_char", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4684,9 +4677,9 @@ API_FUNC(hdata_char) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_char (hdata, pointer, (const char *)name); + result = weechat_hdata_char (hdata, pointer, (const char *)name); - API_RETURN_INT((int)retval); + API_RETURN_INT((int)result); } API_FUNC(hdata_integer) @@ -4695,7 +4688,7 @@ API_FUNC(hdata_integer) struct t_hdata *hdata; void *pointer; char *name; - int retval; + int result; API_INIT_FUNC(1, "hdata_integer", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4705,9 +4698,9 @@ API_FUNC(hdata_integer) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_integer (hdata, pointer, (const char *)name); + result = weechat_hdata_integer (hdata, pointer, (const char *)name); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(hdata_long) @@ -4716,7 +4709,7 @@ API_FUNC(hdata_long) struct t_hdata *hdata; void *pointer; char *name; - long retval; + long result; API_INIT_FUNC(1, "hdata_long", API_RETURN_LONG(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4726,9 +4719,9 @@ API_FUNC(hdata_long) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_long (hdata, pointer, (const char *)name); + result = weechat_hdata_long (hdata, pointer, (const char *)name); - API_RETURN_LONG(retval); + API_RETURN_LONG(result); } API_FUNC(hdata_string) @@ -4737,7 +4730,7 @@ API_FUNC(hdata_string) struct t_hdata *hdata; void *pointer; char *name; - const char *retval; + const char *result; API_INIT_FUNC(1, "hdata_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4747,17 +4740,18 @@ API_FUNC(hdata_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_string (hdata, pointer, (const char *)name); + result = weechat_hdata_string (hdata, pointer, (const char *)name); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } API_FUNC(hdata_pointer) { zend_string *z_hdata, *z_pointer, *z_name; struct t_hdata *hdata; - void *pointer, *retval; + void *pointer; char *name; + const char *result; API_INIT_FUNC(1, "hdata_pointer", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4767,10 +4761,11 @@ API_FUNC(hdata_pointer) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_pointer (hdata, pointer, (const char *)name); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + weechat_hdata_pointer (hdata, pointer, (const char *)name)); + + API_RETURN_STRING(result); } API_FUNC(hdata_time) @@ -4779,7 +4774,7 @@ API_FUNC(hdata_time) struct t_hdata *hdata; void *pointer; char *name; - time_t retval; + time_t result; API_INIT_FUNC(1, "hdata_time", API_RETURN_LONG(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4789,9 +4784,9 @@ API_FUNC(hdata_time) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_time (hdata, pointer, (const char *)name); + result = weechat_hdata_time (hdata, pointer, (const char *)name); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(hdata_hashtable) @@ -4800,7 +4795,7 @@ API_FUNC(hdata_hashtable) struct t_hdata *hdata; void *pointer; char *name; - struct t_hashtable *retval; + struct t_hashtable *result; API_INIT_FUNC(1, "hdata_hashtable", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4810,9 +4805,9 @@ API_FUNC(hdata_hashtable) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); - retval = weechat_hdata_hashtable (hdata, pointer, (const char *)name); + result = weechat_hdata_hashtable (hdata, pointer, (const char *)name); - weechat_php_hashtable_to_array (retval, return_value); + weechat_php_hashtable_to_array (result, return_value); } API_FUNC(hdata_compare) @@ -4822,7 +4817,7 @@ API_FUNC(hdata_compare) struct t_hdata *hdata; void *pointer1, *pointer2; char *name; - int case_sensitive, retval; + int case_sensitive, result; API_INIT_FUNC(1, "hdata_compare", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4835,17 +4830,17 @@ API_FUNC(hdata_compare) pointer2 = (void *)API_STR2PTR(ZSTR_VAL(z_pointer2)); name = (void *)API_STR2PTR(ZSTR_VAL(z_name)); case_sensitive = (int)z_case_sensitive; - retval = weechat_hdata_compare (hdata, pointer1, pointer2, name, + result = weechat_hdata_compare (hdata, pointer1, pointer2, name, case_sensitive); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(hdata_update) { zend_string *z_hdata, *z_pointer; zval *z_hashtable; - int retval; + int result; struct t_hdata *hdata; void *pointer; struct t_hashtable *hashtable; @@ -4863,9 +4858,9 @@ API_FUNC(hdata_update) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); - retval = weechat_hdata_update (hdata, pointer, hashtable); + result = weechat_hdata_update (hdata, pointer, hashtable); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(hdata_get_string) @@ -4873,7 +4868,7 @@ API_FUNC(hdata_get_string) zend_string *z_hdata, *z_property; struct t_hdata *hdata; char *property; - const char *retval; + const char *result; API_INIT_FUNC(1, "hdata_get_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4882,9 +4877,9 @@ API_FUNC(hdata_get_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); property = ZSTR_VAL(z_property); - retval = weechat_hdata_get_string (hdata, (const char *)property); + result = weechat_hdata_get_string (hdata, (const char *)property); - API_RETURN_STRING(retval); + API_RETURN_STRING(result); } static int @@ -4896,18 +4891,13 @@ weechat_php_api_upgrade_read_cb (const void *pointer, void *data, int rc; void *func_argv[4]; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = &object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); weechat_php_cb (pointer, data, func_argv, "ssis", WEECHAT_SCRIPT_EXEC_INT, &rc); - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); - return rc; } @@ -4917,7 +4907,7 @@ API_FUNC(upgrade_new) zval *z_callback_read; char *filename; char *data; - struct t_upgrade_file *retval; + const char *result; API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "SzS", &z_filename, @@ -4927,15 +4917,17 @@ API_FUNC(upgrade_new) filename = ZSTR_VAL(z_filename); weechat_php_get_function_name (z_callback_read, callback_read_name); data = ZSTR_VAL(z_data); - retval = plugin_script_api_upgrade_new (weechat_php_plugin, - php_current_script, - (const char *)filename, - &weechat_php_api_upgrade_read_cb, - (const char *)callback_read_name, - (const char *)data); - char *__retstr = API_PTR2STR(retval); - API_RETURN_STRING_FREE(__retstr); + result = API_PTR2STR( + plugin_script_api_upgrade_new ( + weechat_php_plugin, + php_current_script, + (const char *)filename, + &weechat_php_api_upgrade_read_cb, + (const char *)callback_read_name, + (const char *)data)); + + API_RETURN_STRING(result); } API_FUNC(upgrade_write_object) @@ -4945,7 +4937,7 @@ API_FUNC(upgrade_write_object) struct t_upgrade_file *upgrade_file; int object_id; struct t_infolist *infolist; - int retval; + int result; API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4956,16 +4948,16 @@ API_FUNC(upgrade_write_object) upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file)); object_id = (int)z_object_id; infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); - retval = weechat_upgrade_write_object (upgrade_file, object_id, infolist); + result = weechat_upgrade_write_object (upgrade_file, object_id, infolist); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(upgrade_read) { zend_string *z_upgrade_file; struct t_upgrade_file *upgrade_file; - int retval; + int result; API_INIT_FUNC(1, "upgrade_read", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), @@ -4973,9 +4965,9 @@ API_FUNC(upgrade_read) API_WRONG_ARGS(API_RETURN_INT(0)); upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file)); - retval = weechat_upgrade_read (upgrade_file); + result = weechat_upgrade_read (upgrade_file); - API_RETURN_INT(retval); + API_RETURN_INT(result); } API_FUNC(upgrade_close) diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 720d8bd1d..439e04d6b 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -487,11 +487,11 @@ weechat_php_func_map_get (const char* func_name) return weechat_hashtable_get (weechat_php_func_map, func_name); } -char * +const char * weechat_php_func_map_add (zval *ofunc) { zval *func; - char *func_name; + const char *func_name; if (!weechat_php_func_map) { diff --git a/src/plugins/php/weechat-php.h b/src/plugins/php/weechat-php.h index 64a7d64c3..333840745 100644 --- a/src/plugins/php/weechat-php.h +++ b/src/plugins/php/weechat-php.h @@ -67,7 +67,7 @@ extern struct t_hashtable *weechat_php_array_to_hashtable (zval* arr, const char *type_keys, const char *type_values); extern zval *weechat_php_func_map_get (const char *func_name); -extern char *weechat_php_func_map_add (zval *ofunc); +extern const char *weechat_php_func_map_add (zval *ofunc); extern void *weechat_php_exec (struct t_plugin_script *script, int ret_type, const char *function, diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c index dca382d07..a8b414d35 100644 --- a/src/plugins/plugin-script.c +++ b/src/plugins/plugin-script.c @@ -324,22 +324,24 @@ plugin_script_valid (struct t_plugin_script *scripts, * Converts a pointer to a string for usage in a script. * * Returns string with format "0x12345678". - * - * Note: result must be freed after use. */ -char * +const char * plugin_script_ptr2str (void *pointer) { - char pointer_str[128]; + static char str_pointer[32][32]; + static int index_pointer = 0; + + index_pointer = (index_pointer + 1) % 32; + str_pointer[index_pointer][0] = '\0'; if (!pointer) - return strdup (""); + return str_pointer[index_pointer]; - snprintf (pointer_str, sizeof (pointer_str), + snprintf (str_pointer[index_pointer], sizeof (str_pointer[index_pointer]), "0x%lx", (long unsigned int)pointer); - return strdup (pointer_str); + return str_pointer[index_pointer]; } /* diff --git a/src/plugins/plugin-script.h b/src/plugins/plugin-script.h index 936d67452..cb226876c 100644 --- a/src/plugins/plugin-script.h +++ b/src/plugins/plugin-script.h @@ -119,7 +119,7 @@ extern void plugin_script_init (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script_data *plugin_data); extern int plugin_script_valid (struct t_plugin_script *scripts, struct t_plugin_script *script); -extern char *plugin_script_ptr2str (void *pointer); +extern const char *plugin_script_ptr2str (void *pointer); extern void *plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin, const char *script_name, const char *function_name, diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index def103a5d..5b08c9bb4 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -524,8 +524,7 @@ API_FUNC(mkdir_parents) API_FUNC(list_new) { - char *result; - PyObject *return_value; + const char *result; /* make C compiler happy */ (void) args; @@ -534,13 +533,13 @@ API_FUNC(list_new) result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_add) { - char *weelist, *data, *where, *user_data, *result; - PyObject *return_value; + char *weelist, *data, *where, *user_data; + const char *result; API_INIT_FUNC(1, "list_add", API_RETURN_EMPTY); weelist = NULL; @@ -555,13 +554,13 @@ API_FUNC(list_add) where, API_STR2PTR(user_data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search) { - char *weelist, *data, *result; - PyObject *return_value; + char *weelist, *data; + const char *result; API_INIT_FUNC(1, "list_search", API_RETURN_EMPTY); weelist = NULL; @@ -572,7 +571,7 @@ API_FUNC(list_search) result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search_pos) @@ -593,8 +592,8 @@ API_FUNC(list_search_pos) API_FUNC(list_casesearch) { - char *weelist, *data, *result; - PyObject *return_value; + char *weelist, *data; + const char *result; API_INIT_FUNC(1, "list_casesearch", API_RETURN_EMPTY); weelist = NULL; @@ -605,7 +604,7 @@ API_FUNC(list_casesearch) result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_casesearch_pos) @@ -626,9 +625,9 @@ API_FUNC(list_casesearch_pos) API_FUNC(list_get) { - char *weelist, *result; + char *weelist; + const char *result; int position; - PyObject *return_value; API_INIT_FUNC(1, "list_get", API_RETURN_EMPTY); weelist = NULL; @@ -638,7 +637,7 @@ API_FUNC(list_get) result = API_PTR2STR(weechat_list_get (API_STR2PTR(weelist), position)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_set) @@ -659,8 +658,8 @@ API_FUNC(list_set) API_FUNC(list_next) { - char *item, *result; - PyObject *return_value; + char *item; + const char *result; API_INIT_FUNC(1, "list_next", API_RETURN_EMPTY); item = NULL; @@ -669,13 +668,13 @@ API_FUNC(list_next) result = API_PTR2STR(weechat_list_next (API_STR2PTR(item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_prev) { - char *item, *result; - PyObject *return_value; + char *item; + const char *result; API_INIT_FUNC(1, "list_prev", API_RETURN_EMPTY); item = NULL; @@ -684,7 +683,7 @@ API_FUNC(list_prev) result = API_PTR2STR(weechat_list_prev (API_STR2PTR(item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_string) @@ -777,7 +776,7 @@ weechat_python_api_config_reload_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -791,8 +790,6 @@ weechat_python_api_config_reload_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -802,8 +799,8 @@ weechat_python_api_config_reload_cb (const void *pointer, void *data, API_FUNC(config_new) { - char *name, *function, *data, *result; - PyObject *return_value; + char *name, *function, *data; + const char *result; API_INIT_FUNC(1, "config_new", API_RETURN_EMPTY); name = NULL; @@ -819,7 +816,7 @@ API_FUNC(config_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -840,8 +837,8 @@ weechat_python_api_config_read_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -857,10 +854,6 @@ weechat_python_api_config_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -885,7 +878,7 @@ weechat_python_api_config_section_write_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_python_exec (script, @@ -900,8 +893,6 @@ weechat_python_api_config_section_write_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -926,7 +917,7 @@ weechat_python_api_config_section_write_default_cb (const void *pointer, void *d if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_python_exec (script, @@ -941,8 +932,6 @@ weechat_python_api_config_section_write_default_cb (const void *pointer, void *d ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -969,8 +958,8 @@ weechat_python_api_config_section_create_option_cb (const void *pointer, void *d if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -986,10 +975,6 @@ weechat_python_api_config_section_create_option_cb (const void *pointer, void *d ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1015,9 +1000,9 @@ weechat_python_api_config_section_delete_option_cb (const void *pointer, void *d if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1031,12 +1016,6 @@ weechat_python_api_config_section_delete_option_cb (const void *pointer, void *d ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1049,9 +1028,9 @@ API_FUNC(config_new_section) char *config_file, *name, *function_read, *data_read, *function_write; char *data_write, *function_write_default, *data_write_default; char *function_create_option, *data_create_option, *function_delete_option; - char *data_delete_option, *result; + char *data_delete_option; + const char *result; int user_can_add_options, user_can_delete_options; - PyObject *return_value; API_INIT_FUNC(1, "config_new_section", API_RETURN_EMPTY); config_file = NULL; @@ -1101,13 +1080,13 @@ API_FUNC(config_new_section) function_delete_option, data_delete_option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_section) { - char *config_file, *section_name, *result; - PyObject *return_value; + char *config_file, *section_name; + const char *result; API_INIT_FUNC(1, "config_search_section", API_RETURN_EMPTY); config_file = NULL; @@ -1118,7 +1097,7 @@ API_FUNC(config_search_section) result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), section_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1139,7 +1118,7 @@ weechat_python_api_config_option_check_value_cb (const void *pointer, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_python_exec (script, @@ -1154,8 +1133,6 @@ weechat_python_api_config_option_check_value_cb (const void *pointer, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1179,16 +1156,13 @@ weechat_python_api_config_option_change_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1210,16 +1184,13 @@ weechat_python_api_config_option_delete_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1228,11 +1199,11 @@ weechat_python_api_config_option_delete_cb (const void *pointer, void *data, API_FUNC(config_new_option) { char *config_file, *section, *name, *type, *description, *string_values; - char *default_value, *value, *result; + char *default_value, *value; char *function_check_value, *data_check_value, *function_change; char *data_change, *function_delete, *data_delete; + const char *result; int min, max, null_value_allowed; - PyObject *return_value; API_INIT_FUNC(1, "config_new_option", API_RETURN_EMPTY); config_file = NULL; @@ -1280,13 +1251,13 @@ API_FUNC(config_new_option) function_delete, data_delete)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_option) { - char *config_file, *section, *option_name, *result; - PyObject *return_value; + char *config_file, *section, *option_name; + const char *result; API_INIT_FUNC(1, "config_search_option", API_RETURN_EMPTY); config_file = NULL; @@ -1299,7 +1270,7 @@ API_FUNC(config_search_option) API_STR2PTR(section), option_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_string_to_boolean) @@ -1689,8 +1660,8 @@ API_FUNC(config_free) API_FUNC(config_get) { - char *option, *result; - PyObject *return_value; + char *option; + const char *result; API_INIT_FUNC(1, "config_get", API_RETURN_EMPTY); option = NULL; @@ -1699,7 +1670,7 @@ API_FUNC(config_get) result = API_PTR2STR(weechat_config_get (option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_get_plugin) @@ -1960,7 +1931,7 @@ weechat_python_api_hook_command_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_python_exec (script, @@ -1975,8 +1946,6 @@ weechat_python_api_hook_command_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1987,8 +1956,8 @@ weechat_python_api_hook_command_cb (const void *pointer, void *data, API_FUNC(hook_command) { char *command, *description, *arguments, *args_description, *completion; - char *function, *data, *result; - PyObject *return_value; + char *function, *data; + const char *result; API_INIT_FUNC(1, "hook_command", API_RETURN_EMPTY); command = NULL; @@ -2013,7 +1982,7 @@ API_FUNC(hook_command) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2035,8 +2004,8 @@ weechat_python_api_hook_completion_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -2050,10 +2019,6 @@ weechat_python_api_hook_completion_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -2063,8 +2028,8 @@ weechat_python_api_hook_completion_cb (const void *pointer, void *data, API_FUNC(hook_completion) { - char *completion, *description, *function, *data, *result; - PyObject *return_value; + char *completion, *description, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY); completion = NULL; @@ -2083,7 +2048,7 @@ API_FUNC(hook_completion) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_completion_get_string) @@ -2142,7 +2107,7 @@ weechat_python_api_hook_command_run_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_python_exec (script, @@ -2157,8 +2122,6 @@ weechat_python_api_hook_command_run_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2168,8 +2131,8 @@ weechat_python_api_hook_command_run_cb (const void *pointer, void *data, API_FUNC(hook_command_run) { - char *command, *function, *data, *result; - PyObject *return_value; + char *command, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_command_run", API_RETURN_EMPTY); command = NULL; @@ -2185,7 +2148,7 @@ API_FUNC(hook_command_run) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2231,8 +2194,8 @@ weechat_python_api_hook_timer_cb (const void *pointer, void *data, API_FUNC(hook_timer) { int interval, align_second, max_calls; - char *function, *data, *result; - PyObject *return_value; + char *function, *data; + const char *result; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); interval = 10; @@ -2253,7 +2216,7 @@ API_FUNC(hook_timer) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2299,8 +2262,8 @@ weechat_python_api_hook_fd_cb (const void *pointer, void *data, int fd) API_FUNC(hook_fd) { int fd, read, write, exception; - char *function, *data, *result; - PyObject *return_value; + char *function, *data; + const char *result; API_INIT_FUNC(1, "hook_fd", API_RETURN_EMPTY); fd = 0; @@ -2323,7 +2286,7 @@ API_FUNC(hook_fd) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2392,9 +2355,9 @@ weechat_python_api_hook_process_cb (const void *pointer, void *data, API_FUNC(hook_process) { - char *command, *function, *data, *result; + char *command, *function, *data; + const char *result; int timeout; - PyObject *return_value; API_INIT_FUNC(1, "hook_process", API_RETURN_EMPTY); command = NULL; @@ -2412,15 +2375,16 @@ API_FUNC(hook_process) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_process_hashtable) { - char *command, *function, *data, *result; + char *command, *function, *data; + const char *result; int timeout; struct t_hashtable *options; - PyObject *dict, *return_value; + PyObject *dict; API_INIT_FUNC(1, "hook_process_hashtable", API_RETURN_EMPTY); command = NULL; @@ -2448,7 +2412,7 @@ API_FUNC(hook_process_hashtable) if (options) weechat_hashtable_free (options); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2508,9 +2472,9 @@ weechat_python_api_hook_connect_cb (const void *pointer, void *data, API_FUNC(hook_connect) { - char *proxy, *address, *local_hostname, *function, *data, *result; + char *proxy, *address, *local_hostname, *function, *data; + const char *result; int port, ipv6, retry; - PyObject *return_value; API_INIT_FUNC(1, "hook_connect", API_RETURN_EMPTY); proxy = NULL; @@ -2541,7 +2505,7 @@ API_FUNC(hook_connect) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2570,7 +2534,7 @@ weechat_python_api_hook_print_cb (const void *pointer, void *data, snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2592,8 +2556,6 @@ weechat_python_api_hook_print_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); if (func_argv[3]) free (func_argv[3]); if (func_argv[4]) @@ -2613,9 +2575,9 @@ weechat_python_api_hook_print_cb (const void *pointer, void *data, API_FUNC(hook_print) { - char *buffer, *tags, *message, *function, *data, *result; + char *buffer, *tags, *message, *function, *data; + const char *result; int strip_colors; - PyObject *return_value; API_INIT_FUNC(1, "hook_print", API_RETURN_EMPTY); buffer = NULL; @@ -2638,7 +2600,7 @@ API_FUNC(hook_print) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2651,7 +2613,7 @@ weechat_python_api_hook_signal_cb (const void *pointer, void *data, char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; static char str_value[64]; - int *rc, ret, free_needed; + int *rc, ret; script = (struct t_plugin_script *)pointer; plugin_script_get_function_and_data (data, &ptr_function, &ptr_data); @@ -2660,7 +2622,6 @@ weechat_python_api_hook_signal_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (signal) ? (char *)signal : empty_arg; - free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; @@ -2677,8 +2638,7 @@ weechat_python_api_hook_signal_cb (const void *pointer, void *data, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = API_PTR2STR(signal_data); - free_needed = 1; + func_argv[2] = (char *)API_PTR2STR(signal_data); } else func_argv[2] = empty_arg; @@ -2695,8 +2655,6 @@ weechat_python_api_hook_signal_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (free_needed && func_argv[2]) - free (func_argv[2]); return ret; } @@ -2706,8 +2664,8 @@ weechat_python_api_hook_signal_cb (const void *pointer, void *data, API_FUNC(hook_signal) { - char *signal, *function, *data, *result; - PyObject *return_value; + char *signal, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_signal", API_RETURN_EMPTY); signal = NULL; @@ -2723,7 +2681,7 @@ API_FUNC(hook_signal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_signal_send) @@ -2808,8 +2766,8 @@ weechat_python_api_hook_hsignal_cb (const void *pointer, void *data, API_FUNC(hook_hsignal) { - char *signal, *function, *data, *result; - PyObject *return_value; + char *signal, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_hsignal", API_RETURN_EMPTY); signal = NULL; @@ -2825,7 +2783,7 @@ API_FUNC(hook_hsignal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_hsignal_send) @@ -2894,8 +2852,8 @@ weechat_python_api_hook_config_cb (const void *pointer, void *data, API_FUNC(hook_config) { - char *option, *function, *data, *result; - PyObject *return_value; + char *option, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_config", API_RETURN_EMPTY); option = NULL; @@ -2911,7 +2869,7 @@ API_FUNC(hook_config) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -2946,8 +2904,8 @@ weechat_python_api_hook_modifier_cb (const void *pointer, void *data, API_FUNC(hook_modifier) { - char *modifier, *function, *data, *result; - PyObject *return_value; + char *modifier, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_modifier", API_RETURN_EMPTY); modifier = NULL; @@ -2963,7 +2921,7 @@ API_FUNC(hook_modifier) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_modifier_exec) @@ -3013,8 +2971,8 @@ weechat_python_api_hook_info_cb (const void *pointer, void *data, API_FUNC(hook_info) { - char *info_name, *description, *args_description, *function, *data, *result; - PyObject *return_value; + char *info_name, *description, *args_description, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_info", API_RETURN_EMPTY); info_name = NULL; @@ -3035,7 +2993,7 @@ API_FUNC(hook_info) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3077,8 +3035,8 @@ weechat_python_api_hook_info_hashtable_cb (const void *pointer, void *data, API_FUNC(hook_info_hashtable) { char *info_name, *description, *args_description, *output_description; - char *function, *data, *result; - PyObject *return_value; + char *function, *data; + const char *result; API_INIT_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY); info_name = NULL; @@ -3102,7 +3060,7 @@ API_FUNC(hook_info_hashtable) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_infolist * @@ -3123,7 +3081,7 @@ weechat_python_api_hook_infolist_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_python_exec ( @@ -3132,9 +3090,6 @@ weechat_python_api_hook_infolist_cb (const void *pointer, void *data, ptr_function, "ssss", func_argv); - if (func_argv[2]) - free (func_argv[2]); - return result; } @@ -3144,8 +3099,8 @@ weechat_python_api_hook_infolist_cb (const void *pointer, void *data, API_FUNC(hook_infolist) { char *infolist_name, *description, *pointer_description, *args_description; - char *function, *data, *result; - PyObject *return_value; + char *function, *data; + const char *result; API_INIT_FUNC(1, "hook_infolist", API_RETURN_EMPTY); infolist_name = NULL; @@ -3169,7 +3124,7 @@ API_FUNC(hook_infolist) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3207,8 +3162,8 @@ weechat_python_api_hook_focus_cb (const void *pointer, void *data, API_FUNC(hook_focus) { - char *area, *function, *data, *result; - PyObject *return_value; + char *area, *function, *data; + const char *result; API_INIT_FUNC(1, "hook_focus", API_RETURN_EMPTY); area = NULL; @@ -3224,7 +3179,7 @@ API_FUNC(hook_focus) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_set) @@ -3288,7 +3243,7 @@ weechat_python_api_buffer_input_data_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_python_exec (script, @@ -3302,8 +3257,6 @@ weechat_python_api_buffer_input_data_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3327,7 +3280,7 @@ weechat_python_api_buffer_close_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -3340,8 +3293,6 @@ weechat_python_api_buffer_close_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3352,8 +3303,7 @@ weechat_python_api_buffer_close_cb (const void *pointer, void *data, API_FUNC(buffer_new) { char *name, *function_input, *data_input, *function_close, *data_close; - char *result; - PyObject *return_value; + const char *result; API_INIT_FUNC(1, "buffer_new", API_RETURN_EMPTY); name = NULL; @@ -3375,14 +3325,13 @@ API_FUNC(buffer_new) function_close, data_close)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search) { char *plugin, *name; - char *result; - PyObject *return_value; + const char *result; API_INIT_FUNC(1, "buffer_search", API_RETURN_EMPTY); plugin = NULL; @@ -3392,13 +3341,12 @@ API_FUNC(buffer_search) result = API_PTR2STR(weechat_buffer_search (plugin, name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search_main) { - char *result; - PyObject *return_value; + const char *result; /* make C compiler happy */ (void) args; @@ -3407,13 +3355,12 @@ API_FUNC(buffer_search_main) result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(current_buffer) { - char *result; - PyObject *return_value; + const char *result; /* make C compiler happy */ (void) args; @@ -3422,7 +3369,7 @@ API_FUNC(current_buffer) result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_clear) @@ -3519,8 +3466,8 @@ API_FUNC(buffer_get_string) API_FUNC(buffer_get_pointer) { - char *buffer, *property, *result; - PyObject *return_value; + char *buffer, *property; + const char *result; API_INIT_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY); buffer = NULL; @@ -3531,7 +3478,7 @@ API_FUNC(buffer_get_pointer) result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_set) @@ -3586,8 +3533,7 @@ API_FUNC(buffer_match_list) API_FUNC(current_window) { - char *result; - PyObject *return_value; + const char *result; /* make C compiler happy */ (void) args; @@ -3596,13 +3542,13 @@ API_FUNC(current_window) result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_search_with_buffer) { - char *buffer, *result; - PyObject *return_value; + char *buffer; + const char *result; API_INIT_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY); buffer = NULL; @@ -3611,7 +3557,7 @@ API_FUNC(window_search_with_buffer) result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(buffer))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_get_integer) @@ -3648,8 +3594,8 @@ API_FUNC(window_get_string) API_FUNC(window_get_pointer) { - char *window, *property, *result; - PyObject *return_value; + char *window, *property; + const char *result; API_INIT_FUNC(1, "window_get_pointer", API_RETURN_EMPTY); window = NULL; @@ -3660,7 +3606,7 @@ API_FUNC(window_get_pointer) result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_set_title) @@ -3679,9 +3625,9 @@ API_FUNC(window_set_title) API_FUNC(nicklist_add_group) { - char *buffer, *parent_group, *name, *color, *result; + char *buffer, *parent_group, *name, *color; + const char *result; int visible; - PyObject *return_value; API_INIT_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY); buffer = NULL; @@ -3699,13 +3645,13 @@ API_FUNC(nicklist_add_group) color, visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_group) { - char *buffer, *from_group, *name, *result; - PyObject *return_value; + char *buffer, *from_group, *name; + const char *result; API_INIT_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY); buffer = NULL; @@ -3718,14 +3664,14 @@ API_FUNC(nicklist_search_group) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_add_nick) { - char *buffer, *group, *name, *color, *prefix, *prefix_color, *result; + char *buffer, *group, *name, *color, *prefix, *prefix_color; + const char *result; int visible; - PyObject *return_value; API_INIT_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY); buffer = NULL; @@ -3747,13 +3693,13 @@ API_FUNC(nicklist_add_nick) prefix_color, visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_nick) { - char *buffer, *from_group, *name, *result; - PyObject *return_value; + char *buffer, *from_group, *name; + const char *result; API_INIT_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY); buffer = NULL; @@ -3766,7 +3712,7 @@ API_FUNC(nicklist_search_nick) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_remove_group) @@ -3855,8 +3801,8 @@ API_FUNC(nicklist_group_get_string) API_FUNC(nicklist_group_get_pointer) { - char *buffer, *group, *property, *result; - PyObject *return_value; + char *buffer, *group, *property; + const char *result; API_INIT_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY); buffer = NULL; @@ -3869,7 +3815,7 @@ API_FUNC(nicklist_group_get_pointer) API_STR2PTR(group), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_group_set) @@ -3932,8 +3878,8 @@ API_FUNC(nicklist_nick_get_string) API_FUNC(nicklist_nick_get_pointer) { - char *buffer, *nick, *property, *result; - PyObject *return_value; + char *buffer, *nick, *property; + const char *result; API_INIT_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY); buffer = NULL; @@ -3946,7 +3892,7 @@ API_FUNC(nicklist_nick_get_pointer) API_STR2PTR(nick), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_nick_set) @@ -3971,8 +3917,8 @@ API_FUNC(nicklist_nick_set) API_FUNC(bar_item_search) { - char *name, *result; - PyObject *return_value; + char *name; + const char *result; API_INIT_FUNC(1, "bar_item_search", API_RETURN_EMPTY); name = NULL; @@ -3981,7 +3927,7 @@ API_FUNC(bar_item_search) result = API_PTR2STR(weechat_bar_item_search (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -4005,9 +3951,9 @@ weechat_python_api_bar_item_build_cb (const void *pointer, void *data, { /* new callback: data, item, window, buffer, extra_info */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = weechat_python_hashtable_to_dict (extra_info); ret = (char *)weechat_python_exec (script, @@ -4015,12 +3961,6 @@ weechat_python_api_bar_item_build_cb (const void *pointer, void *data, ptr_function + 7, "ssssO", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); if (func_argv[4]) { Py_XDECREF((PyObject *)func_argv[4]); @@ -4030,18 +3970,13 @@ weechat_python_api_bar_item_build_cb (const void *pointer, void *data, { /* old callback: data, item, window */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); ret = (char *)weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function, "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); } return ret; @@ -4052,8 +3987,8 @@ weechat_python_api_bar_item_build_cb (const void *pointer, void *data, API_FUNC(bar_item_new) { - char *name, *function, *data, *result; - PyObject *return_value; + char *name, *function, *data; + const char *result; API_INIT_FUNC(1, "bar_item_new", API_RETURN_EMPTY); name = NULL; @@ -4069,7 +4004,7 @@ API_FUNC(bar_item_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_item_update) @@ -4102,8 +4037,8 @@ API_FUNC(bar_item_remove) API_FUNC(bar_search) { - char *name, *result; - PyObject *return_value; + char *name; + const char *result; API_INIT_FUNC(1, "bar_search", API_RETURN_EMPTY); name = NULL; @@ -4112,15 +4047,15 @@ API_FUNC(bar_search) result = API_PTR2STR(weechat_bar_search (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_new) { char *name, *hidden, *priority, *type, *conditions, *position; char *filling_top_bottom, *filling_left_right, *size, *size_max; - char *color_fg, *color_delim, *color_bg, *separator, *items, *result; - PyObject *return_value; + char *color_fg, *color_delim, *color_bg, *separator, *items; + const char *result; API_INIT_FUNC(1, "bar_new", API_RETURN_EMPTY); name = NULL; @@ -4160,7 +4095,7 @@ API_FUNC(bar_new) separator, items)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_set) @@ -4273,8 +4208,7 @@ API_FUNC(info_get_hashtable) API_FUNC(infolist_new) { - char *result; - PyObject *return_value; + const char *result; /* make C compiler happy */ (void) args; @@ -4282,13 +4216,13 @@ API_FUNC(infolist_new) API_INIT_FUNC(1, "infolist_new", API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_item) { - char *infolist, *result; - PyObject *return_value; + char *infolist; + const char *result; API_INIT_FUNC(1, "infolist_new_item", API_RETURN_EMPTY); infolist = NULL; @@ -4297,14 +4231,14 @@ API_FUNC(infolist_new_item) result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(infolist))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_integer) { - char *item, *name, *result; + char *item, *name; + const char *result; int value; - PyObject *return_value; API_INIT_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY); item = NULL; @@ -4317,13 +4251,13 @@ API_FUNC(infolist_new_var_integer) name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_string) { - char *item, *name, *value, *result; - PyObject *return_value; + char *item, *name, *value; + const char *result; API_INIT_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY); item = NULL; @@ -4336,13 +4270,13 @@ API_FUNC(infolist_new_var_string) name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_pointer) { - char *item, *name, *value, *result; - PyObject *return_value; + char *item, *name, *value; + const char *result; API_INIT_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY); item = NULL; @@ -4355,14 +4289,14 @@ API_FUNC(infolist_new_var_pointer) name, API_STR2PTR(value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_time) { - char *item, *name, *result; + char *item, *name; + const char *result; int value; - PyObject *return_value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); item = NULL; @@ -4375,13 +4309,13 @@ API_FUNC(infolist_new_var_time) name, value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_search_var) { - char *infolist, *name, *result; - PyObject *return_value; + char *infolist, *name; + const char *result; API_INIT_FUNC(1, "infolist_search_var", API_RETURN_EMPTY); infolist = NULL; @@ -4392,13 +4326,13 @@ API_FUNC(infolist_search_var) result = API_PTR2STR(weechat_infolist_search_var (API_STR2PTR(infolist), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_get) { - char *name, *pointer, *arguments, *result; - PyObject *return_value; + char *name, *pointer, *arguments; + const char *result; API_INIT_FUNC(1, "infolist_get", API_RETURN_EMPTY); name = NULL; @@ -4411,7 +4345,7 @@ API_FUNC(infolist_get) API_STR2PTR(pointer), arguments)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_next) @@ -4509,8 +4443,8 @@ API_FUNC(infolist_string) API_FUNC(infolist_pointer) { - char *infolist, *variable, *result; - PyObject *return_value; + char *infolist, *variable; + const char *result; API_INIT_FUNC(1, "infolist_pointer", API_RETURN_EMPTY); infolist = NULL; @@ -4521,7 +4455,7 @@ API_FUNC(infolist_pointer) result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), variable)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_time) @@ -4567,8 +4501,8 @@ API_FUNC(infolist_free) API_FUNC(hdata_get) { - char *name, *result; - PyObject *return_value; + char *name; + const char *result; API_INIT_FUNC(1, "hdata_get", API_RETURN_EMPTY); name = NULL; @@ -4577,7 +4511,7 @@ API_FUNC(hdata_get) result = API_PTR2STR(weechat_hdata_get (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_offset) @@ -4668,8 +4602,8 @@ API_FUNC(hdata_get_var_hdata) API_FUNC(hdata_get_list) { - char *hdata, *name, *result; - PyObject *return_value; + char *hdata, *name; + const char *result; API_INIT_FUNC(1, "hdata_get_list", API_RETURN_EMPTY); hdata = NULL; @@ -4680,7 +4614,7 @@ API_FUNC(hdata_get_list) result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_check_pointer) @@ -4704,9 +4638,9 @@ API_FUNC(hdata_check_pointer) API_FUNC(hdata_move) { - char *result, *hdata, *pointer; + char *hdata, *pointer; + const char *result; int count; - PyObject *return_value; API_INIT_FUNC(1, "hdata_move", API_RETURN_EMPTY); hdata = NULL; @@ -4719,14 +4653,14 @@ API_FUNC(hdata_move) API_STR2PTR(pointer), count)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_search) { - char *result, *hdata, *pointer, *search; + char *hdata, *pointer, *search; + const char *result; int move; - PyObject *return_value; API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY); hdata = NULL; @@ -4741,7 +4675,7 @@ API_FUNC(hdata_search) search, move)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_char) @@ -4822,8 +4756,8 @@ API_FUNC(hdata_string) API_FUNC(hdata_pointer) { - char *hdata, *pointer, *name, *result; - PyObject *return_value; + char *hdata, *pointer, *name; + const char *result; API_INIT_FUNC(1, "hdata_pointer", API_RETURN_EMPTY); hdata = NULL; @@ -4836,7 +4770,7 @@ API_FUNC(hdata_pointer) API_STR2PTR(pointer), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_time) @@ -4966,9 +4900,9 @@ weechat_python_api_upgrade_read_cb (const void *pointer, void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -4982,10 +4916,6 @@ weechat_python_api_upgrade_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -4995,8 +4925,8 @@ weechat_python_api_upgrade_read_cb (const void *pointer, void *data, API_FUNC(upgrade_new) { - char *filename, *function, *data, *result; - PyObject *return_value; + char *filename, *function, *data; + const char *result; API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY); filename = NULL; @@ -5014,7 +4944,7 @@ API_FUNC(upgrade_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(upgrade_write_object) diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 6c14da64e..eec272e6f 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -644,22 +644,21 @@ weechat_ruby_api_mkdir_parents (VALUE class, VALUE directory, VALUE mode) static VALUE weechat_ruby_api_list_new (VALUE class) { - char *result; - VALUE return_value; + const char *result; API_INIT_FUNC(1, "list_new", API_RETURN_EMPTY); result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_list_add (VALUE class, VALUE weelist, VALUE data, VALUE where, VALUE user_data) { - char *c_weelist, *c_data, *c_where, *c_user_data, *result; - VALUE return_value; + char *c_weelist, *c_data, *c_where, *c_user_data; + const char *result; API_INIT_FUNC(1, "list_add", API_RETURN_EMPTY); if (NIL_P (weelist) || NIL_P (data) || NIL_P (where) || NIL_P (user_data)) @@ -680,14 +679,14 @@ weechat_ruby_api_list_add (VALUE class, VALUE weelist, VALUE data, VALUE where, c_where, API_STR2PTR(c_user_data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data) { - char *c_weelist, *c_data, *result; - VALUE return_value; + char *c_weelist, *c_data; + const char *result; API_INIT_FUNC(1, "list_search", API_RETURN_EMPTY); if (NIL_P (weelist) || NIL_P (data)) @@ -702,7 +701,7 @@ weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data) result = API_PTR2STR(weechat_list_search (API_STR2PTR(c_weelist), c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -729,8 +728,8 @@ weechat_ruby_api_list_search_pos (VALUE class, VALUE weelist, VALUE data) static VALUE weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data) { - char *c_weelist, *c_data, *result; - VALUE return_value; + char *c_weelist, *c_data; + const char *result; API_INIT_FUNC(1, "list_casesearch", API_RETURN_EMPTY); if (NIL_P (weelist) || NIL_P (data)) @@ -745,7 +744,7 @@ weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data) result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(c_weelist), c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -772,9 +771,9 @@ weechat_ruby_api_list_casesearch_pos (VALUE class, VALUE weelist, VALUE data) static VALUE weechat_ruby_api_list_get (VALUE class, VALUE weelist, VALUE position) { - char *c_weelist, *result; + char *c_weelist; + const char *result; int c_position; - VALUE return_value; API_INIT_FUNC(1, "list_get", API_RETURN_EMPTY); if (NIL_P (weelist) || NIL_P (position)) @@ -789,7 +788,7 @@ weechat_ruby_api_list_get (VALUE class, VALUE weelist, VALUE position) result = API_PTR2STR(weechat_list_get (API_STR2PTR(c_weelist), c_position)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -816,8 +815,8 @@ weechat_ruby_api_list_set (VALUE class, VALUE item, VALUE new_value) static VALUE weechat_ruby_api_list_next (VALUE class, VALUE item) { - char *c_item, *result; - VALUE return_value; + char *c_item; + const char *result; API_INIT_FUNC(1, "list_next", API_RETURN_EMPTY); if (NIL_P (item)) @@ -829,14 +828,14 @@ weechat_ruby_api_list_next (VALUE class, VALUE item) result = API_PTR2STR(weechat_list_next (API_STR2PTR(c_item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_list_prev (VALUE class, VALUE item) { - char *c_item, *result; - VALUE return_value; + char *c_item; + const char *result; API_INIT_FUNC(1, "list_prev", API_RETURN_EMPTY); if (NIL_P (item)) @@ -848,7 +847,7 @@ weechat_ruby_api_list_prev (VALUE class, VALUE item) result = API_PTR2STR(weechat_list_prev (API_STR2PTR(c_item))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -962,7 +961,7 @@ weechat_ruby_api_config_reload_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); rc = (int *) weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -976,8 +975,6 @@ weechat_ruby_api_config_reload_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -989,8 +986,8 @@ static VALUE weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function, VALUE data) { - char *c_name, *c_function, *c_data, *result; - VALUE return_value; + char *c_name, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "config_new", API_RETURN_EMPTY); if (NIL_P (name) || NIL_P (function) || NIL_P (data)) @@ -1011,7 +1008,7 @@ weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1032,8 +1029,8 @@ weechat_ruby_api_config_read_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1049,10 +1046,6 @@ weechat_ruby_api_config_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1077,7 +1070,7 @@ weechat_ruby_api_config_section_write_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_ruby_exec (script, @@ -1092,8 +1085,6 @@ weechat_ruby_api_config_section_write_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1118,7 +1109,7 @@ weechat_ruby_api_config_section_write_default_cb (const void *pointer, void *dat if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_ruby_exec (script, @@ -1133,8 +1124,6 @@ weechat_ruby_api_config_section_write_default_cb (const void *pointer, void *dat ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1161,8 +1150,8 @@ weechat_ruby_api_config_section_create_option_cb (const void *pointer, void *dat if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1178,10 +1167,6 @@ weechat_ruby_api_config_section_create_option_cb (const void *pointer, void *dat ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1207,9 +1192,9 @@ weechat_ruby_api_config_section_delete_option_cb (const void *pointer, void *dat if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); rc = (int *) weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1223,12 +1208,6 @@ weechat_ruby_api_config_section_delete_option_cb (const void *pointer, void *dat ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1255,9 +1234,9 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, char *c_function_write, *c_data_write, *c_function_write_default; char *c_data_write_default, *c_function_create_option; char *c_data_create_option, *c_function_delete_option; - char *c_data_delete_option, *result; + char *c_data_delete_option; + const char *result; int c_user_can_add_options, c_user_can_delete_options; - VALUE return_value; API_INIT_FUNC(1, "config_new_section", API_RETURN_EMPTY); if (NIL_P (config_file) || NIL_P (name) || NIL_P (user_can_add_options) @@ -1322,15 +1301,15 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, c_function_delete_option, c_data_delete_option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_config_search_section (VALUE class, VALUE config_file, VALUE section_name) { - char *c_config_file, *c_section_name, *result; - VALUE return_value; + char *c_config_file, *c_section_name; + const char *result; API_INIT_FUNC(1, "config_search_section", API_RETURN_EMPTY); if (NIL_P (config_file) || NIL_P (section_name)) @@ -1345,7 +1324,7 @@ weechat_ruby_api_config_search_section (VALUE class, VALUE config_file, result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(c_config_file), c_section_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1365,7 +1344,7 @@ weechat_ruby_api_config_option_check_value_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_ruby_exec (script, @@ -1380,8 +1359,6 @@ weechat_ruby_api_config_option_check_value_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1405,16 +1382,13 @@ weechat_ruby_api_config_option_change_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1436,16 +1410,13 @@ weechat_ruby_api_config_option_delete_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1462,10 +1433,11 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, char *c_config_file, *c_section, *c_name, *c_type, *c_description; char *c_string_values, *c_default_value, *c_value; char *c_function_check_value, *c_data_check_value, *c_function_change; - char *c_data_change, *c_function_delete, *c_data_delete, *result; + char *c_data_change, *c_function_delete, *c_data_delete; + const char *result; int c_min, c_max, c_null_value_allowed; VALUE function_check_value, data_check_value, function_change, data_change; - VALUE function_delete, data_delete, return_value; + VALUE function_delete, data_delete; API_INIT_FUNC(1, "config_new_option", API_RETURN_EMPTY); if (NIL_P (config_file) || NIL_P (section) || NIL_P (name) || NIL_P (type) @@ -1542,15 +1514,15 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, c_function_delete, c_data_delete)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_config_search_option (VALUE class, VALUE config_file, VALUE section, VALUE option_name) { - char *c_config_file, *c_section, *c_option_name, *result; - VALUE return_value; + char *c_config_file, *c_section, *c_option_name; + const char *result; API_INIT_FUNC(1, "config_search_option", API_RETURN_EMPTY); if (NIL_P (config_file) || NIL_P (section) || NIL_P (option_name)) @@ -1568,7 +1540,7 @@ weechat_ruby_api_config_search_option (VALUE class, VALUE config_file, API_STR2PTR(c_section), c_option_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -2073,8 +2045,8 @@ weechat_ruby_api_config_free (VALUE class, VALUE config_file) static VALUE weechat_ruby_api_config_get (VALUE class, VALUE option) { - char *c_option, *result; - VALUE return_value; + char *c_option; + const char *result; API_INIT_FUNC(1, "config_get", API_RETURN_EMPTY); if (NIL_P (option)) @@ -2086,7 +2058,7 @@ weechat_ruby_api_config_get (VALUE class, VALUE option) result = API_PTR2STR(weechat_config_get (c_option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -2408,7 +2380,7 @@ weechat_ruby_api_hook_command_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_ruby_exec (script, @@ -2423,8 +2395,6 @@ weechat_ruby_api_hook_command_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2438,8 +2408,8 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, VALUE completion, VALUE function, VALUE data) { char *c_command, *c_description, *c_args, *c_args_description; - char *c_completion, *c_function, *c_data, *result; - VALUE return_value; + char *c_completion, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_command", API_RETURN_EMPTY); if (NIL_P (command) || NIL_P (description) || NIL_P (args) @@ -2474,7 +2444,7 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2496,8 +2466,8 @@ weechat_ruby_api_hook_completion_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); rc = (int *) weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -2511,10 +2481,6 @@ weechat_ruby_api_hook_completion_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -2527,8 +2493,8 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion, VALUE description, VALUE function, VALUE data) { - char *c_completion, *c_description, *c_function, *c_data, *result; - VALUE return_value; + char *c_completion, *c_description, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY); if (NIL_P (completion) || NIL_P (description) || NIL_P (function) @@ -2553,7 +2519,7 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -2627,7 +2593,7 @@ weechat_ruby_api_hook_command_run_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_ruby_exec (script, @@ -2642,8 +2608,6 @@ weechat_ruby_api_hook_command_run_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2655,8 +2619,8 @@ static VALUE weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function, VALUE data) { - char *c_command, *c_function, *c_data, *result; - VALUE return_value; + char *c_command, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_command_run", API_RETURN_EMPTY); if (NIL_P (command) || NIL_P (function) || NIL_P (data)) @@ -2677,7 +2641,7 @@ weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2725,8 +2689,8 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, VALUE max_calls, VALUE function, VALUE data) { int c_interval, c_align_second, c_max_calls; - char *c_function, *c_data, *result; - VALUE return_value; + char *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); if (NIL_P (interval) || NIL_P (align_second) || NIL_P (max_calls) @@ -2754,7 +2718,7 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2798,8 +2762,8 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, VALUE exception, VALUE function, VALUE data) { int c_fd, c_read, c_write, c_exception; - char *c_function, *c_data, *result; - VALUE return_value; + char *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_fd", API_RETURN_EMPTY); if (NIL_P (fd) || NIL_P (read) || NIL_P (write) || NIL_P (exception) @@ -2830,7 +2794,7 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2897,9 +2861,9 @@ static VALUE weechat_ruby_api_hook_process (VALUE class, VALUE command, VALUE timeout, VALUE function, VALUE data) { - char *c_command, *c_function, *c_data, *result; + char *c_command, *c_function, *c_data; + const char *result; int c_timeout; - VALUE return_value; API_INIT_FUNC(1, "hook_process", API_RETURN_EMPTY); if (NIL_P (command) || NIL_P (timeout) || NIL_P (function) || NIL_P (data)) @@ -2923,7 +2887,7 @@ weechat_ruby_api_hook_process (VALUE class, VALUE command, VALUE timeout, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -2931,10 +2895,10 @@ weechat_ruby_api_hook_process_hashtable (VALUE class, VALUE command, VALUE options, VALUE timeout, VALUE function, VALUE data) { - char *c_command, *c_function, *c_data, *result; + char *c_command, *c_function, *c_data; + const char *result; struct t_hashtable *c_options; int c_timeout; - VALUE return_value; API_INIT_FUNC(1, "hook_process_hashtable", API_RETURN_EMPTY); if (NIL_P (command) || NIL_P (options) || NIL_P (timeout) @@ -2968,7 +2932,7 @@ weechat_ruby_api_hook_process_hashtable (VALUE class, VALUE command, if (c_options) weechat_hashtable_free (c_options); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -3020,9 +2984,9 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, VALUE local_hostname, VALUE function, VALUE data) { - char *c_proxy, *c_address, *c_local_hostname, *c_function, *c_data, *result; + char *c_proxy, *c_address, *c_local_hostname, *c_function, *c_data; + const char *result; int c_port, c_ipv6, c_retry; - VALUE return_value; API_INIT_FUNC(1, "hook_connect", API_RETURN_EMPTY); if (NIL_P (proxy) || NIL_P (address) || NIL_P (port) || NIL_P (ipv6) @@ -3064,7 +3028,7 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -3093,7 +3057,7 @@ weechat_ruby_api_hook_print_cb (const void *pointer, void *data, snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -3115,8 +3079,6 @@ weechat_ruby_api_hook_print_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); if (func_argv[3]) free (func_argv[3]); @@ -3131,9 +3093,9 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, VALUE message, VALUE strip_colors, VALUE function, VALUE data) { - char *c_buffer, *c_tags, *c_message, *c_function, *c_data, *result; + char *c_buffer, *c_tags, *c_message, *c_function, *c_data; + const char *result; int c_strip_colors; - VALUE return_value; API_INIT_FUNC(1, "hook_print", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (tags) || NIL_P (message) @@ -3164,7 +3126,7 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -3177,7 +3139,7 @@ weechat_ruby_api_hook_signal_cb (const void *pointer, void *data, char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; static char str_value[64]; - int *rc, ret, free_needed; + int *rc, ret; script = (struct t_plugin_script *)pointer; plugin_script_get_function_and_data (data, &ptr_function, &ptr_data); @@ -3186,7 +3148,6 @@ weechat_ruby_api_hook_signal_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (signal) ? (char *)signal : empty_arg; - free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; @@ -3203,8 +3164,7 @@ weechat_ruby_api_hook_signal_cb (const void *pointer, void *data, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = API_PTR2STR(signal_data); - free_needed = 1; + func_argv[2] = (char *)API_PTR2STR(signal_data); } else func_argv[2] = empty_arg; @@ -3221,8 +3181,6 @@ weechat_ruby_api_hook_signal_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (free_needed && func_argv[2]) - free (func_argv[2]); return ret; } @@ -3234,8 +3192,8 @@ static VALUE weechat_ruby_api_hook_signal (VALUE class, VALUE signal, VALUE function, VALUE data) { - char *c_signal, *c_function, *c_data, *result; - VALUE return_value; + char *c_signal, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_signal", API_RETURN_EMPTY); if (NIL_P (signal) || NIL_P (function) || NIL_P (data)) @@ -3256,7 +3214,7 @@ weechat_ruby_api_hook_signal (VALUE class, VALUE signal, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -3345,8 +3303,8 @@ static VALUE weechat_ruby_api_hook_hsignal (VALUE class, VALUE signal, VALUE function, VALUE data) { - char *c_signal, *c_function, *c_data, *result; - VALUE return_value; + char *c_signal, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_hsignal", API_RETURN_EMPTY); if (NIL_P (signal) || NIL_P (function) || NIL_P (data)) @@ -3367,7 +3325,7 @@ weechat_ruby_api_hook_hsignal (VALUE class, VALUE signal, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -3440,8 +3398,8 @@ static VALUE weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function, VALUE data) { - char *c_option, *c_function, *c_data, *result; - VALUE return_value; + char *c_option, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_config", API_RETURN_EMPTY); if (NIL_P (option) || NIL_P (function) || NIL_P (data)) @@ -3462,7 +3420,7 @@ weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -3499,8 +3457,8 @@ static VALUE weechat_ruby_api_hook_modifier (VALUE class, VALUE modifier, VALUE function, VALUE data) { - char *c_modifier, *c_function, *c_data, *result; - VALUE return_value; + char *c_modifier, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_modifier", API_RETURN_EMPTY); if (NIL_P (modifier) || NIL_P (function) || NIL_P (data)) @@ -3521,7 +3479,7 @@ weechat_ruby_api_hook_modifier (VALUE class, VALUE modifier, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -3581,8 +3539,8 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, VALUE args_description, VALUE function, VALUE data) { char *c_info_name, *c_description, *c_args_description, *c_function; - char *c_data, *result; - VALUE return_value; + char *c_data; + const char *result; API_INIT_FUNC(1, "hook_info", API_RETURN_EMPTY); if (NIL_P (info_name) || NIL_P (description) || NIL_P (args_description) @@ -3610,7 +3568,7 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3651,8 +3609,8 @@ weechat_ruby_api_hook_info_hashtable (VALUE class, VALUE info_name, { char *c_info_name, *c_description, *c_args_description; char *c_output_description, *c_function; - char *c_data, *result; - VALUE return_value; + char *c_data; + const char *result; API_INIT_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY); if (NIL_P (info_name) || NIL_P (description) || NIL_P (args_description) @@ -3683,7 +3641,7 @@ weechat_ruby_api_hook_info_hashtable (VALUE class, VALUE info_name, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_infolist * @@ -3704,7 +3662,7 @@ weechat_ruby_api_hook_infolist_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_ruby_exec ( @@ -3713,9 +3671,6 @@ weechat_ruby_api_hook_infolist_cb (const void *pointer, void *data, ptr_function, "ssss", func_argv); - if (func_argv[2]) - free (func_argv[2]); - return result; } @@ -3729,8 +3684,8 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, VALUE data) { char *c_infolist_name, *c_description, *c_pointer_description; - char *c_args_description, *c_function, *c_data, *result; - VALUE return_value; + char *c_args_description, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_infolist", API_RETURN_EMPTY); if (NIL_P (infolist_name) || NIL_P (description) @@ -3762,7 +3717,7 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3796,8 +3751,8 @@ static VALUE weechat_ruby_api_hook_focus (VALUE class, VALUE area, VALUE function, VALUE data) { - char *c_area, *c_function, *c_data, *result; - VALUE return_value; + char *c_area, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "hook_focus", API_RETURN_EMPTY); if (NIL_P (area) || NIL_P (function) || NIL_P (data)) @@ -3818,7 +3773,7 @@ weechat_ruby_api_hook_focus (VALUE class, VALUE area, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -3891,7 +3846,7 @@ weechat_ruby_api_buffer_input_data_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_ruby_exec (script, @@ -3906,8 +3861,6 @@ weechat_ruby_api_buffer_input_data_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3931,7 +3884,7 @@ weechat_ruby_api_buffer_close_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); rc = (int *) weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -3945,8 +3898,6 @@ weechat_ruby_api_buffer_close_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3960,8 +3911,8 @@ weechat_ruby_api_buffer_new (VALUE class, VALUE name, VALUE function_input, VALUE data_close) { char *c_name, *c_function_input, *c_data_input, *c_function_close; - char *c_data_close, *result; - VALUE return_value; + char *c_data_close; + const char *result; API_INIT_FUNC(1, "buffer_new", API_RETURN_EMPTY); if (NIL_P (name) || NIL_P (function_input) || NIL_P (data_input) @@ -3990,14 +3941,14 @@ weechat_ruby_api_buffer_new (VALUE class, VALUE name, VALUE function_input, c_function_close, c_data_close)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) { - char *c_plugin, *c_name, *result; - VALUE return_value; + char *c_plugin, *c_name; + const char *result; API_INIT_FUNC(1, "buffer_search", API_RETURN_EMPTY); if (NIL_P (plugin) || NIL_P (name)) @@ -4011,33 +3962,31 @@ weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) result = API_PTR2STR(weechat_buffer_search (c_plugin, c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_buffer_search_main (VALUE class) { - char *result; - VALUE return_value; + const char *result; API_INIT_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_current_buffer (VALUE class) { - char *result; - VALUE return_value; + const char *result; API_INIT_FUNC(1, "current_buffer", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4165,8 +4114,8 @@ weechat_ruby_api_buffer_get_string (VALUE class, VALUE buffer, VALUE property) static VALUE weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property) { - char *c_buffer, *c_property, *result; - VALUE return_value; + char *c_buffer, *c_property; + const char *result; API_INIT_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (property)) @@ -4181,7 +4130,7 @@ weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property) result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(c_buffer), c_property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4255,21 +4204,20 @@ weechat_ruby_api_buffer_match_list (VALUE class, VALUE buffer, VALUE string) static VALUE weechat_ruby_api_current_window (VALUE class) { - char *result; - VALUE return_value; + const char *result; API_INIT_FUNC(1, "current_window", API_RETURN_EMPTY); result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_window_search_with_buffer (VALUE class, VALUE buffer) { - char *c_buffer, *result; - VALUE return_value; + char *c_buffer; + const char *result; API_INIT_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY); if (NIL_P (buffer)) @@ -4281,7 +4229,7 @@ weechat_ruby_api_window_search_with_buffer (VALUE class, VALUE buffer) result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(c_buffer))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4331,8 +4279,8 @@ weechat_ruby_api_window_get_string (VALUE class, VALUE window, VALUE property) static VALUE weechat_ruby_api_window_get_pointer (VALUE class, VALUE window, VALUE property) { - char *c_window, *c_property, *result; - VALUE return_value; + char *c_window, *c_property; + const char *result; API_INIT_FUNC(1, "window_get_pointer", API_RETURN_EMPTY); if (NIL_P (window) || NIL_P (property)) @@ -4347,7 +4295,7 @@ weechat_ruby_api_window_get_pointer (VALUE class, VALUE window, VALUE property) result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(c_window), c_property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4373,9 +4321,9 @@ weechat_ruby_api_nicklist_add_group (VALUE class, VALUE buffer, VALUE parent_group, VALUE name, VALUE color, VALUE visible) { - char *c_buffer, *c_parent_group, *c_name, *c_color, *result; + char *c_buffer, *c_parent_group, *c_name, *c_color; + const char *result; int c_visible; - VALUE return_value; API_INIT_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (parent_group) || NIL_P (name) || NIL_P (color) @@ -4400,15 +4348,15 @@ weechat_ruby_api_nicklist_add_group (VALUE class, VALUE buffer, c_color, c_visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_nicklist_search_group (VALUE class, VALUE buffer, VALUE from_group, VALUE name) { - char *c_buffer, *c_from_group, *c_name, *result; - VALUE return_value; + char *c_buffer, *c_from_group, *c_name; + const char *result; API_INIT_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (from_group) || NIL_P (name)) @@ -4426,7 +4374,7 @@ weechat_ruby_api_nicklist_search_group (VALUE class, VALUE buffer, API_STR2PTR(c_from_group), c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4435,9 +4383,8 @@ weechat_ruby_api_nicklist_add_nick (VALUE class, VALUE buffer, VALUE group, VALUE prefix_color, VALUE visible) { char *c_buffer, *c_group, *c_name, *c_color, *c_prefix, *c_prefix_color; - char *result; + const char *result; int c_visible; - VALUE return_value; API_INIT_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (group) || NIL_P (name) || NIL_P (color) @@ -4468,15 +4415,15 @@ weechat_ruby_api_nicklist_add_nick (VALUE class, VALUE buffer, VALUE group, c_prefix_color, c_visible)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_nicklist_search_nick (VALUE class, VALUE buffer, VALUE from_group, VALUE name) { - char *c_buffer, *c_from_group, *c_name, *result; - VALUE return_value; + char *c_buffer, *c_from_group, *c_name; + const char *result; API_INIT_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (from_group) || NIL_P (name)) @@ -4494,7 +4441,7 @@ weechat_ruby_api_nicklist_search_nick (VALUE class, VALUE buffer, API_STR2PTR(c_from_group), c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4613,8 +4560,8 @@ static VALUE weechat_ruby_api_nicklist_group_get_pointer (VALUE class, VALUE buffer, VALUE group, VALUE property) { - char *c_buffer, *c_group, *c_property, *result; - VALUE return_value; + char *c_buffer, *c_group, *c_property; + const char *result; API_INIT_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (group) || NIL_P (property)) @@ -4632,7 +4579,7 @@ weechat_ruby_api_nicklist_group_get_pointer (VALUE class, VALUE buffer, API_STR2PTR(c_group), c_property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4719,8 +4666,8 @@ static VALUE weechat_ruby_api_nicklist_nick_get_pointer (VALUE class, VALUE buffer, VALUE nick, VALUE property) { - char *c_buffer, *c_nick, *c_property, *result; - VALUE return_value; + char *c_buffer, *c_nick, *c_property; + const char *result; API_INIT_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY); if (NIL_P (buffer) || NIL_P (nick) || NIL_P (property)) @@ -4738,7 +4685,7 @@ weechat_ruby_api_nicklist_nick_get_pointer (VALUE class, VALUE buffer, API_STR2PTR(c_nick), c_property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4772,8 +4719,8 @@ weechat_ruby_api_nicklist_nick_set (VALUE class, VALUE buffer, VALUE nick, static VALUE weechat_ruby_api_bar_item_search (VALUE class, VALUE name) { - char *c_name, *result; - VALUE return_value; + char *c_name; + const char *result; API_INIT_FUNC(1, "bar_item_search", API_RETURN_EMPTY); if (NIL_P (name)) @@ -4785,7 +4732,7 @@ weechat_ruby_api_bar_item_search (VALUE class, VALUE name) result = API_PTR2STR(weechat_bar_item_search (c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -4809,39 +4756,27 @@ weechat_ruby_api_bar_item_build_cb (const void *pointer, void *data, { /* new callback: data, item, window, buffer, extra_info */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = extra_info; ret = (char *)weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function + 7, "ssssh", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); } else { /* old callback: data, item, window */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); ret = (char *)weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function, "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); } return ret; @@ -4854,8 +4789,8 @@ static VALUE weechat_ruby_api_bar_item_new (VALUE class, VALUE name, VALUE function, VALUE data) { - char *c_name, *c_function, *c_data, *result; - VALUE return_value; + char *c_name, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "bar_item_new", API_RETURN_EMPTY); if (NIL_P (name) || NIL_P (function) || NIL_P (data)) @@ -4876,7 +4811,7 @@ weechat_ruby_api_bar_item_new (VALUE class, VALUE name, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4918,8 +4853,8 @@ weechat_ruby_api_bar_item_remove (VALUE class, VALUE item) static VALUE weechat_ruby_api_bar_search (VALUE class, VALUE name) { - char *c_name, *result; - VALUE return_value; + char *c_name; + const char *result; API_INIT_FUNC(1, "bar_search", API_RETURN_EMPTY); if (NIL_P (name)) @@ -4931,7 +4866,7 @@ weechat_ruby_api_bar_search (VALUE class, VALUE name) result = API_PTR2STR(weechat_bar_search (c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -4945,8 +4880,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE hidden, char *c_name, *c_hidden, *c_priority, *c_type, *c_conditions, *c_position; char *c_filling_top_bottom, *c_filling_left_right, *c_size, *c_size_max; char *c_color_fg, *c_color_delim, *c_color_bg, *c_separator, *c_items; - char *result; - VALUE return_value; + const char *result; API_INIT_FUNC(1, "bar_new", API_RETURN_EMPTY); if (NIL_P (name) || NIL_P (hidden) || NIL_P (priority) || NIL_P (type) @@ -5004,7 +4938,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE hidden, c_separator, c_items)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -5146,21 +5080,20 @@ weechat_ruby_api_info_get_hashtable (VALUE class, VALUE info_name, static VALUE weechat_ruby_api_infolist_new (VALUE class) { - char *result; - VALUE return_value; + const char *result; API_INIT_FUNC(1, "infolist_new", API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_infolist_new_item (VALUE class, VALUE infolist) { - char *c_infolist, *result; - VALUE return_value; + char *c_infolist; + const char *result; API_INIT_FUNC(1, "infolist_new_item", API_RETURN_EMPTY); if (NIL_P (infolist)) @@ -5172,16 +5105,16 @@ weechat_ruby_api_infolist_new_item (VALUE class, VALUE infolist) result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(c_infolist))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_infolist_new_var_integer (VALUE class, VALUE item, VALUE name, VALUE value) { - char *c_item, *c_name, *result; + char *c_item, *c_name; + const char *result; int c_value; - VALUE return_value; API_INIT_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY); if (NIL_P (item) || NIL_P (name) || NIL_P (value)) @@ -5199,15 +5132,15 @@ weechat_ruby_api_infolist_new_var_integer (VALUE class, VALUE item, c_name, c_value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_infolist_new_var_string (VALUE class, VALUE item, VALUE name, VALUE value) { - char *c_item, *c_name, *c_value, *result; - VALUE return_value; + char *c_item, *c_name, *c_value; + const char *result; API_INIT_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY); if (NIL_P (item) || NIL_P (name) || NIL_P (value)) @@ -5225,15 +5158,15 @@ weechat_ruby_api_infolist_new_var_string (VALUE class, VALUE item, c_name, c_value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_infolist_new_var_pointer (VALUE class, VALUE item, VALUE name, VALUE value) { - char *c_item, *c_name, *c_value, *result; - VALUE return_value; + char *c_item, *c_name, *c_value; + const char *result; API_INIT_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY); if (NIL_P (item) || NIL_P (name) || NIL_P (value)) @@ -5251,16 +5184,16 @@ weechat_ruby_api_infolist_new_var_pointer (VALUE class, VALUE item, c_name, API_STR2PTR(c_value))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_infolist_new_var_time (VALUE class, VALUE item, VALUE name, VALUE value) { - char *c_item, *c_name, *result; + char *c_item, *c_name; + const char *result; int c_value; - VALUE return_value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); if (NIL_P (item) || NIL_P (name) || NIL_P (value)) @@ -5278,14 +5211,14 @@ weechat_ruby_api_infolist_new_var_time (VALUE class, VALUE item, c_name, c_value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_infolist_search_var (VALUE class, VALUE infolist, VALUE name) { - char *c_infolist, *c_name, *result; - VALUE return_value; + char *c_infolist, *c_name; + const char *result; API_INIT_FUNC(1, "infolist_search_var", API_RETURN_EMPTY); if (NIL_P (infolist) || NIL_P (name)) @@ -5300,15 +5233,15 @@ weechat_ruby_api_infolist_search_var (VALUE class, VALUE infolist, VALUE name) result = API_PTR2STR(weechat_infolist_search_var (API_STR2PTR(c_infolist), c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_infolist_get (VALUE class, VALUE name, VALUE pointer, VALUE arguments) { - char *c_name, *c_pointer, *c_arguments, *result; - VALUE return_value; + char *c_name, *c_pointer, *c_arguments; + const char *result; API_INIT_FUNC(1, "infolist_get", API_RETURN_EMPTY); if (NIL_P (name) || NIL_P (pointer) || NIL_P (arguments)) @@ -5326,7 +5259,7 @@ weechat_ruby_api_infolist_get (VALUE class, VALUE name, VALUE pointer, API_STR2PTR(c_pointer), c_arguments)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -5449,8 +5382,8 @@ weechat_ruby_api_infolist_string (VALUE class, VALUE infolist, VALUE variable) static VALUE weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable) { - char *c_infolist, *c_variable, *result; - VALUE return_value; + char *c_infolist, *c_variable; + const char *result; API_INIT_FUNC(1, "infolist_pointer", API_RETURN_EMPTY); if (NIL_P (infolist) || NIL_P (variable)) @@ -5464,7 +5397,7 @@ weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable) result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(c_infolist), c_variable)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -5519,8 +5452,8 @@ weechat_ruby_api_infolist_free (VALUE class, VALUE infolist) static VALUE weechat_ruby_api_hdata_get (VALUE class, VALUE name) { - char *c_name, *result; - VALUE return_value; + char *c_name; + const char *result; API_INIT_FUNC(1, "hdata_get", API_RETURN_EMPTY); if (NIL_P (name)) @@ -5532,7 +5465,7 @@ weechat_ruby_api_hdata_get (VALUE class, VALUE name) result = API_PTR2STR(weechat_hdata_get (c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -5654,8 +5587,8 @@ weechat_ruby_api_hdata_get_var_hdata (VALUE class, VALUE hdata, VALUE name) static VALUE weechat_ruby_api_hdata_get_list (VALUE class, VALUE hdata, VALUE name) { - char *c_hdata, *c_name, *result; - VALUE return_value; + char *c_hdata, *c_name; + const char *result; API_INIT_FUNC(1, "hdata_get_list", API_RETURN_EMPTY); if (NIL_P (hdata) || NIL_P (name)) @@ -5670,7 +5603,7 @@ weechat_ruby_api_hdata_get_list (VALUE class, VALUE hdata, VALUE name) result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(c_hdata), c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -5703,9 +5636,9 @@ static VALUE weechat_ruby_api_hdata_move (VALUE class, VALUE hdata, VALUE pointer, VALUE count) { - char *c_hdata, *c_pointer, *result; + char *c_hdata, *c_pointer; + const char *result; int c_count; - VALUE return_value; API_INIT_FUNC(1, "hdata_move", API_RETURN_EMPTY); if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (count)) @@ -5723,16 +5656,16 @@ weechat_ruby_api_hdata_move (VALUE class, VALUE hdata, VALUE pointer, API_STR2PTR(c_pointer), c_count)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE weechat_ruby_api_hdata_search (VALUE class, VALUE hdata, VALUE pointer, VALUE search, VALUE move) { - char *c_hdata, *c_pointer, *c_search, *result; + char *c_hdata, *c_pointer, *c_search; + const char *result; int c_move; - VALUE return_value; API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY); if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (search) || NIL_P (move)) @@ -5753,7 +5686,7 @@ weechat_ruby_api_hdata_search (VALUE class, VALUE hdata, VALUE pointer, c_search, c_move)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -5864,8 +5797,8 @@ static VALUE weechat_ruby_api_hdata_pointer (VALUE class, VALUE hdata, VALUE pointer, VALUE name) { - char *c_hdata, *c_pointer, *c_name, *result; - VALUE return_value; + char *c_hdata, *c_pointer, *c_name; + const char *result; API_INIT_FUNC(1, "hdata_pointer", API_RETURN_EMPTY); if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name)) @@ -5883,7 +5816,7 @@ weechat_ruby_api_hdata_pointer (VALUE class, VALUE hdata, VALUE pointer, API_STR2PTR(c_pointer), c_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE @@ -6048,9 +5981,9 @@ weechat_ruby_api_upgrade_read_cb (const void *pointer, void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); rc = (int *) weechat_ruby_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -6064,10 +5997,6 @@ weechat_ruby_api_upgrade_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -6079,8 +6008,8 @@ static VALUE weechat_ruby_api_upgrade_new (VALUE class, VALUE filename, VALUE function, VALUE data) { - char *c_filename, *c_function, *c_data, *result; - VALUE return_value; + char *c_filename, *c_function, *c_data; + const char *result; API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY); if (NIL_P (filename) || NIL_P (function) || NIL_P (data)) @@ -6103,7 +6032,7 @@ weechat_ruby_api_upgrade_new (VALUE class, VALUE filename, VALUE function, c_function, c_data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } static VALUE diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 7a1df5a7f..876f4224f 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -692,7 +692,7 @@ API_FUNC(mkdir_parents) API_FUNC(list_new) { Tcl_Obj *objp; - char *result; + const char *result; /* make C compiler happy */ (void) clientData; @@ -703,13 +703,14 @@ API_FUNC(list_new) result = API_PTR2STR(weechat_list_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_add) { Tcl_Obj *objp; - char *result, *weelist, *data, *where, *user_data; + char *weelist, *data, *where, *user_data; + const char *result; int i; @@ -727,13 +728,14 @@ API_FUNC(list_add) where, API_STR2PTR(user_data))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search) { Tcl_Obj *objp; - char *result, *weelist, *data; + char *weelist, *data; + const char *result; int i; API_INIT_FUNC(1, "list_search", API_RETURN_EMPTY); @@ -746,7 +748,7 @@ API_FUNC(list_search) result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_search_pos) @@ -770,7 +772,8 @@ API_FUNC(list_search_pos) API_FUNC(list_casesearch) { Tcl_Obj *objp; - char *result, *weelist, *data; + char *weelist, *data; + const char *result; int i; API_INIT_FUNC(1, "list_casesearch", API_RETURN_EMPTY); @@ -783,7 +786,7 @@ API_FUNC(list_casesearch) result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_casesearch_pos) @@ -807,7 +810,7 @@ API_FUNC(list_casesearch_pos) API_FUNC(list_get) { Tcl_Obj *objp; - char *result; + const char *result; int i, position; API_INIT_FUNC(1, "list_get", API_RETURN_EMPTY); @@ -820,7 +823,7 @@ API_FUNC(list_get) result = API_PTR2STR(weechat_list_get (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* weelist */ position)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_set) @@ -844,7 +847,7 @@ API_FUNC(list_set) API_FUNC(list_next) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "list_next", API_RETURN_EMPTY); @@ -853,13 +856,13 @@ API_FUNC(list_next) result = API_PTR2STR(weechat_list_next (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* item */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_prev) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "list_prev", API_RETURN_EMPTY); @@ -868,7 +871,7 @@ API_FUNC(list_prev) result = API_PTR2STR(weechat_list_prev (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* item */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(list_string) @@ -967,7 +970,7 @@ weechat_tcl_api_config_reload_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); rc = (int *) weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -981,8 +984,6 @@ weechat_tcl_api_config_reload_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -993,7 +994,8 @@ weechat_tcl_api_config_reload_cb (const void *pointer, void *data, API_FUNC(config_new) { Tcl_Obj *objp; - char *result, *name, *function, *data; + char *name, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "config_new", API_RETURN_EMPTY); @@ -1011,7 +1013,7 @@ API_FUNC(config_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -1032,8 +1034,8 @@ weechat_tcl_api_config_section_read_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1049,10 +1051,6 @@ weechat_tcl_api_config_section_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1077,7 +1075,7 @@ weechat_tcl_api_config_section_write_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_tcl_exec (script, @@ -1092,8 +1090,6 @@ weechat_tcl_api_config_section_write_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1118,7 +1114,7 @@ weechat_tcl_api_config_section_write_default_cb (const void *pointer, void *data if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); + func_argv[1] = (char *)API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_tcl_exec (script, @@ -1133,8 +1129,6 @@ weechat_tcl_api_config_section_write_default_cb (const void *pointer, void *data ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1161,8 +1155,8 @@ weechat_tcl_api_config_section_create_option_cb (const void *pointer, void *data if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1178,10 +1172,6 @@ weechat_tcl_api_config_section_create_option_cb (const void *pointer, void *data ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); return ret; } @@ -1207,9 +1197,9 @@ weechat_tcl_api_config_section_delete_option_cb (const void *pointer, void *data if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(config_file); - func_argv[2] = API_PTR2STR(section); - func_argv[3] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(config_file); + func_argv[2] = (char *)API_PTR2STR(section); + func_argv[3] = (char *)API_PTR2STR(option); rc = (int *) weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -1223,12 +1213,6 @@ weechat_tcl_api_config_section_delete_option_cb (const void *pointer, void *data ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -1239,10 +1223,11 @@ weechat_tcl_api_config_section_delete_option_cb (const void *pointer, void *data API_FUNC(config_new_section) { Tcl_Obj *objp; - char *result, *cfg_file, *name, *function_read, *data_read; + char *cfg_file, *name, *function_read, *data_read; char *function_write, *data_write, *function_write_default; char *data_write_default, *function_create_option, *data_create_option; char *function_delete_option, *data_delete_option; + const char *result; int i, can_add, can_delete; /* make C compiler happy */ @@ -1293,13 +1278,14 @@ API_FUNC(config_new_section) function_delete_option, data_delete_option)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_section) { Tcl_Obj *objp; - char *result, *config_file, *section_name; + char *config_file, *section_name; + const char *result; int i; API_INIT_FUNC(1, "config_search_section", API_RETURN_EMPTY); @@ -1312,7 +1298,7 @@ API_FUNC(config_search_section) result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), section_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } @@ -1333,7 +1319,7 @@ weechat_tcl_api_config_option_check_value_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_tcl_exec (script, @@ -1348,8 +1334,6 @@ weechat_tcl_api_config_option_check_value_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -1373,16 +1357,13 @@ weechat_tcl_api_config_option_change_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1404,16 +1385,13 @@ weechat_tcl_api_config_option_delete_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(option); + func_argv[1] = (char *)API_PTR2STR(option); rc = (int *) weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_INT, ptr_function, "ss", func_argv); - if (func_argv[1]) - free (func_argv[1]); - if (rc) free (rc); } @@ -1422,10 +1400,11 @@ weechat_tcl_api_config_option_delete_cb (const void *pointer, void *data, API_FUNC(config_new_option) { Tcl_Obj *objp; - char *result, *config_file, *section, *name, *type; + char *config_file, *section, *name, *type; char *description, *string_values, *default_value, *value; char *function_check_value, *data_check_value, *function_change; char *data_change, *function_delete, *data_delete; + const char *result; int i, min, max, null_value_allowed; API_INIT_FUNC(1, "config_new_option", API_RETURN_EMPTY); @@ -1475,13 +1454,14 @@ API_FUNC(config_new_option) function_delete, data_delete)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_search_option) { Tcl_Obj *objp; - char *result, *config_file, *section, *option_name; + char *config_file, *section, *option_name; + const char *result; int i; API_INIT_FUNC(1, "config_search_option", API_RETURN_EMPTY); @@ -1496,7 +1476,7 @@ API_FUNC(config_search_option) API_STR2PTR(section), option_name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_string_to_boolean) @@ -1909,7 +1889,7 @@ API_FUNC(config_free) API_FUNC(config_get) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "config_get", API_RETURN_EMPTY); @@ -1918,7 +1898,7 @@ API_FUNC(config_get) result = API_PTR2STR(weechat_config_get (Tcl_GetStringFromObj (objv[1], &i))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(config_get_plugin) @@ -2204,7 +2184,7 @@ weechat_tcl_api_hook_command_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_tcl_exec (script, @@ -2219,8 +2199,6 @@ weechat_tcl_api_hook_command_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2231,8 +2209,9 @@ weechat_tcl_api_hook_command_cb (const void *pointer, void *data, API_FUNC(hook_command) { Tcl_Obj *objp; - char *result, *command, *description, *args, *args_description; + char *command, *description, *args, *args_description; char *completion, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_command", API_RETURN_EMPTY); @@ -2258,7 +2237,7 @@ API_FUNC(hook_command) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2280,8 +2259,8 @@ weechat_tcl_api_hook_completion_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = API_PTR2STR(buffer); - func_argv[3] = API_PTR2STR(completion); + func_argv[2] = (char *)API_PTR2STR(buffer); + func_argv[3] = (char *)API_PTR2STR(completion); rc = (int *) weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -2295,10 +2274,6 @@ weechat_tcl_api_hook_completion_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -2309,7 +2284,8 @@ weechat_tcl_api_hook_completion_cb (const void *pointer, void *data, API_FUNC(hook_completion) { Tcl_Obj *objp; - char *result, *completion, *description, *function, *data; + char *completion, *description, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY); @@ -2329,7 +2305,7 @@ API_FUNC(hook_completion) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_completion_get_string) @@ -2394,7 +2370,7 @@ weechat_tcl_api_hook_command_run_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_tcl_exec (script, @@ -2409,8 +2385,6 @@ weechat_tcl_api_hook_command_run_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -2421,7 +2395,8 @@ weechat_tcl_api_hook_command_run_cb (const void *pointer, void *data, API_FUNC(hook_command_run) { Tcl_Obj *objp; - char *result, *command, *function, *data; + char *command, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_command_run", API_RETURN_EMPTY); @@ -2439,7 +2414,7 @@ API_FUNC(hook_command_run) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2485,7 +2460,7 @@ weechat_tcl_api_hook_timer_cb (const void *pointer, void *data, API_FUNC(hook_timer) { Tcl_Obj *objp; - char *result; + const char *result; int i, interval, align_second, max_calls; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); @@ -2507,7 +2482,7 @@ API_FUNC(hook_timer) Tcl_GetStringFromObj (objv[4], &i), /* tcl function */ Tcl_GetStringFromObj (objv[5], &i))); /* data */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2549,7 +2524,7 @@ weechat_tcl_api_hook_fd_cb (const void *pointer, void *data, int fd) API_FUNC(hook_fd) { Tcl_Obj *objp; - char *result; + const char *result; int i, fd, read, write, exception; API_INIT_FUNC(1, "hook_fd", API_RETURN_EMPTY); @@ -2572,7 +2547,7 @@ API_FUNC(hook_fd) Tcl_GetStringFromObj (objv[5], &i), /* tcl function */ Tcl_GetStringFromObj (objv[6], &i))); /* data */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2638,7 +2613,8 @@ weechat_tcl_api_hook_process_cb (const void *pointer, void *data, API_FUNC(hook_process) { Tcl_Obj *objp; - char *command, *function, *data, *result; + char *command, *function, *data; + const char *result; int i, timeout; API_INIT_FUNC(1, "hook_process", API_RETURN_EMPTY); @@ -2660,13 +2636,14 @@ API_FUNC(hook_process) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_process_hashtable) { Tcl_Obj *objp; - char *command, *function, *data, *result; + char *command, *function, *data; + const char *result; struct t_hashtable *options; int i, timeout; @@ -2697,7 +2674,7 @@ API_FUNC(hook_process_hashtable) if (options) weechat_hashtable_free (options); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2746,7 +2723,8 @@ weechat_tcl_api_hook_connect_cb (const void *pointer, void *data, API_FUNC(hook_connect) { Tcl_Obj *objp; - char *proxy, *address, *local_hostname, *function, *data, *result; + char *proxy, *address, *local_hostname, *function, *data; + const char *result; int i, port, ipv6, retry; API_INIT_FUNC(1, "hook_connect", API_RETURN_EMPTY); @@ -2780,7 +2758,7 @@ API_FUNC(hook_connect) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2809,7 +2787,7 @@ weechat_tcl_api_hook_print_cb (const void *pointer, void *data, snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2831,8 +2809,6 @@ weechat_tcl_api_hook_print_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); if (func_argv[3]) free (func_argv[3]); @@ -2845,7 +2821,8 @@ weechat_tcl_api_hook_print_cb (const void *pointer, void *data, API_FUNC(hook_print) { Tcl_Obj *objp; - char *result, *buffer, *tags, *message, *function, *data; + char *buffer, *tags, *message, *function, *data; + const char *result; int i, strip_colors; API_INIT_FUNC(1, "hook_print", API_RETURN_EMPTY); @@ -2871,7 +2848,7 @@ API_FUNC(hook_print) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } int @@ -2884,7 +2861,7 @@ weechat_tcl_api_hook_signal_cb (const void *pointer, void *data, char empty_arg[1] = { '\0' }; const char *ptr_function, *ptr_data; static char str_value[64]; - int *rc, ret, free_needed; + int *rc, ret; script = (struct t_plugin_script *)pointer; plugin_script_get_function_and_data (data, &ptr_function, &ptr_data); @@ -2893,7 +2870,6 @@ weechat_tcl_api_hook_signal_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (signal) ? (char *)signal : empty_arg; - free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; @@ -2910,8 +2886,7 @@ weechat_tcl_api_hook_signal_cb (const void *pointer, void *data, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = API_PTR2STR(signal_data); - free_needed = 1; + func_argv[2] = (char *)API_PTR2STR(signal_data); } else func_argv[2] = empty_arg; @@ -2928,8 +2903,6 @@ weechat_tcl_api_hook_signal_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (free_needed && func_argv[2]) - free (func_argv[2]); return ret; } @@ -2940,7 +2913,8 @@ weechat_tcl_api_hook_signal_cb (const void *pointer, void *data, API_FUNC(hook_signal) { Tcl_Obj *objp; - char *result, *signal, *function, *data; + char *signal, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_signal", API_RETURN_EMPTY); @@ -2958,7 +2932,7 @@ API_FUNC(hook_signal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_signal_send) @@ -3044,7 +3018,8 @@ weechat_tcl_api_hook_hsignal_cb (const void *pointer, void *data, API_FUNC(hook_hsignal) { Tcl_Obj *objp; - char *result, *signal, *function, *data; + char *signal, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_hsignal", API_RETURN_EMPTY); @@ -3062,7 +3037,7 @@ API_FUNC(hook_hsignal) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_hsignal_send) @@ -3131,7 +3106,8 @@ weechat_tcl_api_hook_config_cb (const void *pointer, void *data, API_FUNC(hook_config) { Tcl_Obj *objp; - char *result, *option, *function, *data; + char *option, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_config", API_RETURN_EMPTY); @@ -3149,7 +3125,7 @@ API_FUNC(hook_config) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -3185,7 +3161,8 @@ weechat_tcl_api_hook_modifier_cb (const void *pointer, void *data, API_FUNC(hook_modifier) { Tcl_Obj *objp; - char *result, *modifier, *function, *data; + char *modifier, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_modifier", API_RETURN_EMPTY); @@ -3203,7 +3180,7 @@ API_FUNC(hook_modifier) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_modifier_exec) @@ -3256,7 +3233,8 @@ weechat_tcl_api_hook_info_cb (const void *pointer, void *data, API_FUNC(hook_info) { Tcl_Obj *objp; - char *result, *info_name, *description, *args_description, *function, *data; + char *info_name, *description, *args_description, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_info", API_RETURN_EMPTY); @@ -3278,7 +3256,7 @@ API_FUNC(hook_info) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3313,8 +3291,9 @@ weechat_tcl_api_hook_info_hashtable_cb (const void *pointer, void *data, API_FUNC(hook_info_hashtable) { Tcl_Obj *objp; - char *result, *info_name, *description, *args_description; + char *info_name, *description, *args_description; char *output_description, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY); @@ -3338,7 +3317,7 @@ API_FUNC(hook_info_hashtable) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_infolist * @@ -3359,7 +3338,7 @@ weechat_tcl_api_hook_infolist_cb (const void *pointer, void *data, { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = API_PTR2STR(obj_pointer); + func_argv[2] = (char *)API_PTR2STR(obj_pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_tcl_exec ( @@ -3368,9 +3347,6 @@ weechat_tcl_api_hook_infolist_cb (const void *pointer, void *data, ptr_function, "ssss", func_argv); - if (func_argv[2]) - free (func_argv[2]); - return result; } @@ -3380,8 +3356,9 @@ weechat_tcl_api_hook_infolist_cb (const void *pointer, void *data, API_FUNC(hook_infolist) { Tcl_Obj *objp; - char *result, *infolist_name, *description, *pointer_description; + char *infolist_name, *description, *pointer_description; char *args_description, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_infolist", API_RETURN_EMPTY); @@ -3405,7 +3382,7 @@ API_FUNC(hook_infolist) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } struct t_hashtable * @@ -3438,7 +3415,8 @@ weechat_tcl_api_hook_focus_cb (const void *pointer, void *data, API_FUNC(hook_focus) { Tcl_Obj *objp; - char *result, *area, *function, *data; + char *area, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "hook_focus", API_RETURN_EMPTY); @@ -3456,7 +3434,7 @@ API_FUNC(hook_focus) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hook_set) @@ -3526,7 +3504,7 @@ weechat_tcl_api_buffer_input_data_cb (const void *pointer, void *data, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_tcl_exec (script, @@ -3540,8 +3518,6 @@ weechat_tcl_api_buffer_input_data_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3565,7 +3541,7 @@ weechat_tcl_api_buffer_close_cb (const void *pointer, if (ptr_function && ptr_function[0]) { func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(buffer); rc = (int *) weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -3578,8 +3554,6 @@ weechat_tcl_api_buffer_close_cb (const void *pointer, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); return ret; } @@ -3590,8 +3564,8 @@ weechat_tcl_api_buffer_close_cb (const void *pointer, API_FUNC(buffer_new) { Tcl_Obj *objp; - char *result, *name, *function_input, *data_input, *function_close; - char *data_close; + char *name, *function_input, *data_input, *function_close, *data_close; + const char *result; int i; API_INIT_FUNC(1, "buffer_new", API_RETURN_EMPTY); @@ -3614,13 +3588,14 @@ API_FUNC(buffer_new) function_close, data_close)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search) { Tcl_Obj *objp; - char *result, *plugin, *name; + char *plugin, *name; + const char *result; int i; API_INIT_FUNC(1, "buffer_search", API_RETURN_EMPTY); @@ -3632,13 +3607,13 @@ API_FUNC(buffer_search) result = API_PTR2STR(weechat_buffer_search (plugin, name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_search_main) { Tcl_Obj *objp; - char *result; + const char *result; /* make C compiler happy */ (void) clientData; @@ -3649,13 +3624,13 @@ API_FUNC(buffer_search_main) result = API_PTR2STR(weechat_buffer_search_main ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(current_buffer) { Tcl_Obj *objp; - char *result; + const char *result; /* make C compiler happy */ (void) clientData; @@ -3666,7 +3641,7 @@ API_FUNC(current_buffer) result = API_PTR2STR(weechat_current_buffer ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_clear) @@ -3772,7 +3747,8 @@ API_FUNC(buffer_get_string) API_FUNC(buffer_get_pointer) { Tcl_Obj *objp; - char *buffer, *property, *result; + char *buffer, *property; + const char *result; int i; API_INIT_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY); @@ -3785,7 +3761,7 @@ API_FUNC(buffer_get_pointer) result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(buffer_set) @@ -3847,7 +3823,7 @@ API_FUNC(buffer_match_list) API_FUNC(current_window) { Tcl_Obj *objp; - char *result; + const char *result; /* make C compiler happy */ (void) clientData; @@ -3858,13 +3834,14 @@ API_FUNC(current_window) result = API_PTR2STR(weechat_current_window ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_search_with_buffer) { Tcl_Obj *objp; - char *buffer, *result; + char *buffer; + const char *result; int i; API_INIT_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY); @@ -3875,7 +3852,7 @@ API_FUNC(window_search_with_buffer) result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(buffer))); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_get_integer) @@ -3919,7 +3896,8 @@ API_FUNC(window_get_string) API_FUNC(window_get_pointer) { Tcl_Obj *objp; - char *window, *property, *result; + char *window, *property; + const char *result; int i; API_INIT_FUNC(1, "window_get_pointer", API_RETURN_EMPTY); @@ -3932,7 +3910,7 @@ API_FUNC(window_get_pointer) result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(window_set_title) @@ -3955,7 +3933,8 @@ API_FUNC(window_set_title) API_FUNC(nicklist_add_group) { Tcl_Obj *objp; - char *result, *buffer, *parent_group, *name, *color; + char *buffer, *parent_group, *name, *color; + const char *result; int i, visible; API_INIT_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY); @@ -3976,13 +3955,14 @@ API_FUNC(nicklist_add_group) color, visible)); /* visible */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_group) { Tcl_Obj *objp; - char *result, *buffer, *from_group, *name; + char *buffer, *from_group, *name; + const char *result; int i; API_INIT_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY); @@ -3997,13 +3977,14 @@ API_FUNC(nicklist_search_group) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_add_nick) { Tcl_Obj *objp; - char *result, *buffer, *group, *name, *color, *prefix, *prefix_color; + char *buffer, *group, *name, *color, *prefix, *prefix_color; + const char *result; int i, visible; API_INIT_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY); @@ -4028,13 +4009,14 @@ API_FUNC(nicklist_add_nick) prefix_color, visible)); /* visible */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_search_nick) { Tcl_Obj *objp; - char *result, *buffer, *from_group, *name; + char *buffer, *from_group, *name; + const char *result; int i; API_INIT_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY); @@ -4049,7 +4031,7 @@ API_FUNC(nicklist_search_nick) API_STR2PTR(from_group), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_remove_group) @@ -4151,7 +4133,8 @@ API_FUNC(nicklist_group_get_string) API_FUNC(nicklist_group_get_pointer) { Tcl_Obj *objp; - char *buffer, *group, *property, *result; + char *buffer, *group, *property; + const char *result; int i; API_INIT_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY); @@ -4166,7 +4149,7 @@ API_FUNC(nicklist_group_get_pointer) API_STR2PTR(group), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_group_set) @@ -4239,7 +4222,8 @@ API_FUNC(nicklist_nick_get_string) API_FUNC(nicklist_nick_get_pointer) { Tcl_Obj *objp; - char *buffer, *nick, *property, *result; + char *buffer, *nick, *property; + const char *result; int i; API_INIT_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY); @@ -4254,7 +4238,7 @@ API_FUNC(nicklist_nick_get_pointer) API_STR2PTR(nick), property)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(nicklist_nick_set) @@ -4283,7 +4267,7 @@ API_FUNC(nicklist_nick_set) API_FUNC(bar_item_search) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "bar_item_search", API_RETURN_EMPTY); @@ -4292,7 +4276,7 @@ API_FUNC(bar_item_search) result = API_PTR2STR(weechat_bar_item_search (Tcl_GetStringFromObj (objv[1], &i))); /* name */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } char * @@ -4316,39 +4300,27 @@ weechat_tcl_api_bar_item_build_cb (const void *pointer, void *data, { /* new callback: data, item, window, buffer, extra_info */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - func_argv[3] = API_PTR2STR(buffer); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); + func_argv[3] = (char *)API_PTR2STR(buffer); func_argv[4] = extra_info; ret = (char *)weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function + 7, "ssssh", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); - if (func_argv[3]) - free (func_argv[3]); } else { /* old callback: data, item, window */ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); + func_argv[1] = (char *)API_PTR2STR(item); + func_argv[2] = (char *)API_PTR2STR(window); ret = (char *)weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_STRING, ptr_function, "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); } return ret; @@ -4360,7 +4332,8 @@ weechat_tcl_api_bar_item_build_cb (const void *pointer, void *data, API_FUNC(bar_item_new) { Tcl_Obj *objp; - char *result, *name, *function, *data; + char *name, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "bar_item_new", API_RETURN_EMPTY); @@ -4378,7 +4351,7 @@ API_FUNC(bar_item_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_item_update) @@ -4413,7 +4386,7 @@ API_FUNC(bar_item_remove) API_FUNC(bar_search) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "bar_search", API_RETURN_EMPTY); @@ -4422,15 +4395,16 @@ API_FUNC(bar_search) result = API_PTR2STR(weechat_bar_search (Tcl_GetStringFromObj (objv[1], &i))); /* name */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_new) { Tcl_Obj *objp; - char *result, *name, *hidden, *priority, *type, *conditions, *position; + char *name, *hidden, *priority, *type, *conditions, *position; char *filling_top_bottom, *filling_left_right, *size, *size_max, *color_fg; char *color_delim, *color_bg, *separator, *bar_items; + const char *result; int i; API_INIT_FUNC(1, "bar_new", API_RETURN_EMPTY); @@ -4469,7 +4443,7 @@ API_FUNC(bar_new) separator, bar_items)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(bar_set) @@ -4586,7 +4560,7 @@ API_FUNC(info_get_hashtable) API_FUNC(infolist_new) { Tcl_Obj *objp; - char *result; + const char *result; /* make C compiler happy */ (void) clientData; @@ -4597,13 +4571,13 @@ API_FUNC(infolist_new) result = API_PTR2STR(weechat_infolist_new ()); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_item) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "infolist_new_item", API_RETURN_EMPTY); @@ -4612,13 +4586,13 @@ API_FUNC(infolist_new_item) result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* infolist */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_integer) { Tcl_Obj *objp; - char *result; + const char *result; int i, value; API_INIT_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY); @@ -4632,13 +4606,13 @@ API_FUNC(infolist_new_var_integer) Tcl_GetStringFromObj (objv[2], &i), /* name */ value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_string) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY); @@ -4649,13 +4623,13 @@ API_FUNC(infolist_new_var_string) Tcl_GetStringFromObj (objv[2], &i), /* name */ Tcl_GetStringFromObj (objv[3], &i))); /* value */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_pointer) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY); @@ -4666,13 +4640,13 @@ API_FUNC(infolist_new_var_pointer) Tcl_GetStringFromObj (objv[2], &i), /* name */ API_STR2PTR(Tcl_GetStringFromObj (objv[3], &i)))); /* value */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_new_var_time) { Tcl_Obj *objp; - char *result; + const char *result; int i, value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); @@ -4686,13 +4660,13 @@ API_FUNC(infolist_new_var_time) Tcl_GetStringFromObj (objv[2], &i), /* name */ value)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_search_var) { Tcl_Obj *objp; - char *result; + const char *result; int i; API_INIT_FUNC(1, "infolist_search_var", API_RETURN_EMPTY); @@ -4702,13 +4676,14 @@ API_FUNC(infolist_search_var) result = API_PTR2STR(weechat_infolist_search_var (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ Tcl_GetStringFromObj (objv[2], &i))); /* name */ - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_get) { Tcl_Obj *objp; - char *result, *name, *pointer, *arguments; + char *name, *pointer, *arguments; + const char *result; int i; API_INIT_FUNC(1, "infolist_get", API_RETURN_EMPTY); @@ -4723,7 +4698,7 @@ API_FUNC(infolist_get) API_STR2PTR(pointer), arguments)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_next) @@ -4823,7 +4798,8 @@ API_FUNC(infolist_string) API_FUNC(infolist_pointer) { Tcl_Obj *objp; - char *infolist, *variable, *result; + char *infolist, *variable; + const char *result; int i; API_INIT_FUNC(1, "infolist_pointer", API_RETURN_EMPTY); @@ -4835,7 +4811,7 @@ API_FUNC(infolist_pointer) result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), variable)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(infolist_time) @@ -4883,7 +4859,8 @@ API_FUNC(infolist_free) API_FUNC(hdata_get) { Tcl_Obj *objp; - char *result, *name; + char *name; + const char *result; int i; API_INIT_FUNC(1, "hdata_get", API_RETURN_EMPTY); @@ -4894,7 +4871,7 @@ API_FUNC(hdata_get) result = API_PTR2STR(weechat_hdata_get (name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_get_var_offset) @@ -4999,7 +4976,8 @@ API_FUNC(hdata_get_var_hdata) API_FUNC(hdata_get_list) { Tcl_Obj *objp; - char *hdata, *name, *result; + char *hdata, *name; + const char *result; int i; API_INIT_FUNC(1, "hdata_get_list", API_RETURN_EMPTY); @@ -5012,7 +4990,7 @@ API_FUNC(hdata_get_list) result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_check_pointer) @@ -5039,7 +5017,8 @@ API_FUNC(hdata_check_pointer) API_FUNC(hdata_move) { Tcl_Obj *objp; - char *hdata, *pointer, *result; + char *hdata, *pointer; + const char *result; int i, count; API_INIT_FUNC(1, "hdata_move", API_RETURN_EMPTY); @@ -5056,13 +5035,14 @@ API_FUNC(hdata_move) API_STR2PTR(pointer), count)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_search) { Tcl_Obj *objp; - char *hdata, *pointer, *search, *result; + char *hdata, *pointer, *search; + const char *result; int i, move; API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY); @@ -5081,7 +5061,7 @@ API_FUNC(hdata_search) search, move)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_char) @@ -5172,7 +5152,8 @@ API_FUNC(hdata_string) API_FUNC(hdata_pointer) { Tcl_Obj *objp; - char *hdata, *pointer, *name, *result; + char *hdata, *pointer, *name; + const char *result; int i; API_INIT_FUNC(1, "hdata_pointer", API_RETURN_EMPTY); @@ -5187,7 +5168,7 @@ API_FUNC(hdata_pointer) API_STR2PTR(pointer), name)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(hdata_time) @@ -5329,9 +5310,9 @@ weechat_tcl_api_upgrade_read_cb (const void *pointer, void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg; - func_argv[1] = API_PTR2STR(upgrade_file); + func_argv[1] = (char *)API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = API_PTR2STR(infolist); + func_argv[3] = (char *)API_PTR2STR(infolist); rc = (int *) weechat_tcl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -5345,10 +5326,6 @@ weechat_tcl_api_upgrade_read_cb (const void *pointer, void *data, ret = *rc; free (rc); } - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[3]) - free (func_argv[3]); return ret; } @@ -5359,7 +5336,8 @@ weechat_tcl_api_upgrade_read_cb (const void *pointer, void *data, API_FUNC(upgrade_new) { Tcl_Obj *objp; - char *result, *filename, *function, *data; + char *filename, *function, *data; + const char *result; int i; API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY); @@ -5379,7 +5357,7 @@ API_FUNC(upgrade_new) function, data)); - API_RETURN_STRING_FREE(result); + API_RETURN_STRING(result); } API_FUNC(upgrade_write_object) |