Add FullConfig destructor

This commit is contained in:
Vftdan 2024-08-15 21:25:18 +02:00
parent 245563ec8b
commit 5875575d0b
3 changed files with 20 additions and 0 deletions

View File

@ -135,3 +135,21 @@ load_config(const config_setting_t *config_root, FullConfig *config)
config->channels = load_channels_section(channel_config);
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;
}
}

View File

@ -33,5 +33,6 @@ typedef struct {
} FullConfig;
bool load_config(const config_setting_t *config_root, FullConfig *config);
void reset_config(FullConfig *config);
#endif /* end of include guard: CONFIG_H_ */

1
main.c
View File

@ -85,6 +85,7 @@ main(int argc, char ** argv)
free(channels);
free(nodes);
reset_config(&loaded_config);
config_destroy(&config_tree);
io_subscription_list_deinit(&state.wait_output);