diff options
-rw-r--r-- | src/plugins/api.c | 2 | ||||
-rw-r--r-- | src/plugins/api.h | 2 | ||||
-rw-r--r-- | src/plugins/c_api.c | 2 | ||||
-rw-r--r-- | src/plugins/profapi.c | 2 | ||||
-rw-r--r-- | src/plugins/profapi.h | 2 | ||||
-rw-r--r-- | src/plugins/python_api.c | 27 |
6 files changed, 28 insertions, 9 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c index 8ac4856f..8011dee5 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -107,7 +107,7 @@ api_cons_bad_cmd_usage(const char *const cmd) void api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args, - const char **synopsis, const char *description, const char *arguments[][2], const char **examples, + char **synopsis, const char *description, char *arguments[][2], char **examples, void *callback, void(*callback_exec)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback)) { PluginCommand *command = malloc(sizeof(PluginCommand)); diff --git a/src/plugins/api.h b/src/plugins/api.h index db1417cf..5886dae2 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -51,7 +51,7 @@ char* api_get_current_nick(void); char** api_get_current_occupants(void); void api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args, - const char **synopsis, const char *description, const char *arguments[][2], const char **examples, + char **synopsis, const char *description, char *arguments[][2], char **examples, void *callback, void(*callback_func)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback)); void api_register_timed(const char *const plugin_name, void *callback, int interval_seconds, void (*callback_func)(PluginTimedFunction *timed_function), void(*callback_destroy)(void *callback)); diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 67116d31..042010db 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -82,7 +82,7 @@ c_api_cons_bad_cmd_usage(const char *const cmd) static void c_api_register_command(const char *filename, const char *command_name, int min_args, int max_args, - const char **synopsis, const char *description, const char *arguments[][2], const char **examples, + char **synopsis, const char *description, char *arguments[][2], char **examples, void(*callback)(char **args)) { char *plugin_name = _c_plugin_name(filename); diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index bbe570df..e5f46cb4 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -43,7 +43,7 @@ int (*prof_cons_show_themed)(const char *const group, const char *const item, co int (*prof_cons_bad_cmd_usage)(const char *const cmd) = NULL; void (*_prof_register_command)(const char *filename, const char *command_name, int min_args, int max_args, - const char **synopsis, const char *description, const char *arguments[][2], const char **examples, + char **synopsis, const char *description, char *arguments[][2], char **examples, void(*callback)(char **args)) = NULL; void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds) = NULL; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index 1e2e8b01..c75b8f03 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -50,7 +50,7 @@ int (*prof_cons_show_themed)(const char *const group, const char *const item, co int (*prof_cons_bad_cmd_usage)(const char *const cmd); void (*_prof_register_command)(const char *filename, const char *command_name, int min_args, int max_args, - const char **synopsis, const char *description, const char *arguments[][2], const char **examples, + char **synopsis, const char *description, char *arguments[][2], char **examples, void(*callback)(char **args)); void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds); diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index c5a1ef80..08611d33 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -148,7 +148,7 @@ python_api_register_command(PyObject *self, PyObject *args) if (p_callback && PyCallable_Check(p_callback)) { Py_ssize_t len = PyList_Size(synopsis); - const char *c_synopsis[len == 0 ? 0 : len+1]; + char *c_synopsis[len == 0 ? 0 : len+1]; Py_ssize_t i = 0; for (i = 0; i < len; i++) { PyObject *item = PyList_GetItem(synopsis, i); @@ -158,7 +158,7 @@ python_api_register_command(PyObject *self, PyObject *args) c_synopsis[len] = NULL; Py_ssize_t args_len = PyList_Size(arguments); - const char *c_arguments[args_len == 0 ? 0 : args_len+1][2]; + char *c_arguments[args_len == 0 ? 0 : args_len+1][2]; i = 0; for (i = 0; i < args_len; i++) { PyObject *item = PyList_GetItem(arguments, i); @@ -179,7 +179,7 @@ python_api_register_command(PyObject *self, PyObject *args) c_arguments[args_len][1] = NULL; len = PyList_Size(examples); - const char *c_examples[len == 0 ? 0 : len+1]; + char *c_examples[len == 0 ? 0 : len+1]; i = 0; for (i = 0; i < len; i++) { PyObject *item = PyList_GetItem(examples, i); @@ -193,6 +193,20 @@ python_api_register_command(PyObject *self, PyObject *args) description_str, c_arguments, c_examples, p_callback, python_command_callback, NULL); free(command_name_str); free(description_str); + i = 0; + while (c_synopsis[i] != NULL) { + free(c_synopsis[i++]); + } + i = 0; + while (c_arguments[i] != NULL && c_arguments[i][0] != NULL) { + free(c_arguments[i][0]); + free(c_arguments[i][1]); + i++; + } + i = 0; + while (c_examples[i] != NULL) { + free(c_examples[i++]); + } disable_python_threads(); } @@ -254,6 +268,10 @@ python_api_completer_add(PyObject *self, PyObject *args) allow_python_threads(); api_completer_add(plugin_name, key_str, c_items); free(key_str); + i = 0; + while (c_items[i] != NULL) { + free(c_items[i++]); + } disable_python_threads(); free(plugin_name); @@ -993,8 +1011,9 @@ _python_plugin_name(void) { PyThreadState *ts = PyThreadState_Get(); PyFrameObject *frame = ts->frame; - char const* filename = python_str_or_unicode_to_string(frame->f_code->co_filename); + char* filename = python_str_or_unicode_to_string(frame->f_code->co_filename); gchar **split = g_strsplit(filename, "/", 0); + free(filename); char *plugin_name = strdup(split[g_strv_length(split)-1]); g_strfreev(split); |