Add FullConfig destructor
This commit is contained in:
parent
245563ec8b
commit
5875575d0b
18
config.c
18
config.c
|
@ -135,3 +135,21 @@ load_config(const config_setting_t *config_root, FullConfig *config)
|
||||||
config->channels = load_channels_section(channel_config);
|
config->channels = load_channels_section(channel_config);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
reset_config(FullConfig *config)
|
||||||
|
{
|
||||||
|
if (!config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (config->nodes.items) {
|
||||||
|
free(config->nodes.items);
|
||||||
|
config->nodes.items = NULL;
|
||||||
|
config->nodes.length = 0;
|
||||||
|
}
|
||||||
|
if (config->channels.items) {
|
||||||
|
free(config->channels.items);
|
||||||
|
config->channels.items = NULL;
|
||||||
|
config->channels.length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
1
config.h
1
config.h
|
@ -33,5 +33,6 @@ typedef struct {
|
||||||
} FullConfig;
|
} FullConfig;
|
||||||
|
|
||||||
bool load_config(const config_setting_t *config_root, FullConfig *config);
|
bool load_config(const config_setting_t *config_root, FullConfig *config);
|
||||||
|
void reset_config(FullConfig *config);
|
||||||
|
|
||||||
#endif /* end of include guard: CONFIG_H_ */
|
#endif /* end of include guard: CONFIG_H_ */
|
||||||
|
|
1
main.c
1
main.c
|
@ -85,6 +85,7 @@ main(int argc, char ** argv)
|
||||||
free(channels);
|
free(channels);
|
||||||
free(nodes);
|
free(nodes);
|
||||||
|
|
||||||
|
reset_config(&loaded_config);
|
||||||
config_destroy(&config_tree);
|
config_destroy(&config_tree);
|
||||||
|
|
||||||
io_subscription_list_deinit(&state.wait_output);
|
io_subscription_list_deinit(&state.wait_output);
|
||||||
|
|
Loading…
Reference in New Issue