diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2007-12-01 10:49:15 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2007-12-01 10:49:15 +0100 |
commit | 5c579ec3b88e61a4f6f61e7dc8cbf9621a1ec2f5 (patch) | |
tree | 6de03db27736d3befe879848281df87649ed7766 | |
parent | d9755e237b12cc5c22857e4ef720cbbcf11173d7 (diff) | |
download | weechat-5c579ec3b88e61a4f6f61e7dc8cbf9621a1ec2f5.zip |
Remove all plugin options before reloading plugins.rc file (with /reload command)
-rw-r--r-- | src/plugins/plugin-config.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c index d21418101..b2976e72a 100644 --- a/src/plugins/plugin-config.c +++ b/src/plugins/plugin-config.c @@ -239,6 +239,49 @@ plugin_config_set (char *plugin_name, char *option_name, char *value) } /* + * plugin_config_free: free a plugin option and remove it from list + */ + +void +plugin_config_free (struct t_config_option *option) +{ + struct t_config_option *new_plugin_options; + + /* remove option from list */ + if (last_plugin_option == option) + last_plugin_option = option->prev_option; + if (option->prev_option) + { + (option->prev_option)->next_option = option->next_option; + new_plugin_options = plugin_options; + } + else + new_plugin_options = option->next_option; + + if (option->next_option) + (option->next_option)->prev_option = option->prev_option; + + /* free data */ + if (option->name) + free (option->name); + if (option->value) + free (option->value); + free (option); + plugin_options = new_plugin_options; +} + +/* + * plugin_config_free_all: free all plugin options + */ + +void +plugin_config_free_all () +{ + while (plugin_options) + plugin_config_free (plugin_options); +} + +/* * plugin_config_read_option: read an option in config file * Return: 0 = successful * -1 = option not found @@ -319,6 +362,10 @@ plugin_config_read () int plugin_config_reload () { + /* remove all plugin options */ + plugin_config_free_all (); + + /* reload plugins config file */ return config_file_reload (plugin_config); } |