diff options
author | James Booth <boothj5@gmail.com> | 2012-10-22 00:29:39 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-22 00:29:39 +0100 |
commit | 3f8813bb1b24e273d9cc3172e35b1932c06b0af0 (patch) | |
tree | bccf5da60bc7abe569a487ae98951acf8bd74d3e | |
parent | 5353bb47d63c187cdb607a92cca341b2753671dc (diff) | |
download | profani-tty-3f8813bb1b24e273d9cc3172e35b1932c06b0af0.tar.gz |
Free autocompleters on quit
-rw-r--r-- | src/command.c | 19 | ||||
-rw-r--r-- | src/command.h | 1 | ||||
-rw-r--r-- | src/preferences.c | 1 | ||||
-rw-r--r-- | src/profanity.c | 2 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/command.c b/src/command.c index 0248303d..79b92ffc 100644 --- a/src/command.c +++ b/src/command.c @@ -367,25 +367,32 @@ cmd_init(void) unsigned int i; for (i = 0; i < ARRAY_SIZE(main_commands); i++) { struct cmd_t *pcmd = main_commands+i; - p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd); - p_autocomplete_add(help_ac, (gchar *)pcmd->cmd+1); + p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); + p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); } for (i = 0; i < ARRAY_SIZE(setting_commands); i++) { struct cmd_t *pcmd = setting_commands+i; - p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd); - p_autocomplete_add(help_ac, (gchar *)pcmd->cmd+1); + p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); + p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); } for (i = 0; i < ARRAY_SIZE(status_commands); i++) { struct cmd_t *pcmd = status_commands+i; - p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd); - p_autocomplete_add(help_ac, (gchar *)pcmd->cmd+1); + p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); + p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); } history_init(); } +void +cmd_close(void) +{ + p_autocomplete_clear(commands_ac); + p_autocomplete_clear(help_ac); +} + // Command autocompletion functions char * diff --git a/src/command.h b/src/command.h index 105af9f8..c15b6bd5 100644 --- a/src/command.h +++ b/src/command.h @@ -33,6 +33,7 @@ struct cmd_help_t { }; void cmd_init(void); +void cmd_close(void); char * cmd_complete(char *inp); void cmd_reset_completer(void); gboolean cmd_execute(const char * const command, const char * const inp); diff --git a/src/preferences.c b/src/preferences.c index 2c536dde..870ce051 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -117,6 +117,7 @@ prefs_load(void) void prefs_close(void) { + p_autocomplete_clear(ac); g_key_file_free(prefs); } diff --git a/src/profanity.c b/src/profanity.c index 220ae376..1045662b 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -308,8 +308,10 @@ _shutdown_init(void) static void _shutdown(void) { + contact_list_clear(); gui_close(); chat_log_close(); prefs_close(); + cmd_close(); log_close(); } |