diff options
Diffstat (limited to 'src/plugins/lua')
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 377 |
1 files changed, 156 insertions, 221 deletions
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) |