}
static void nw_config_free(struct nw_config* config) {
- struct nw_config_entry* entry = NULL;
-
- while (!STAILQ_EMPTY(&config->entries)) {
- entry = STAILQ_FIRST(&config->entries);
- STAILQ_REMOVE_HEAD(&config->entries, nodes);
-
- // Free the entry
- nw_config_entry_free(entry);
- }
+ // Flush all entries
+ nw_config_flush(config);
free(config);
}
return NULL;
}
+int nw_config_flush(struct nw_config* config) {
+ struct nw_config_entry* entry = NULL;
+
+ while (!STAILQ_EMPTY(&config->entries)) {
+ entry = STAILQ_FIRST(&config->entries);
+ STAILQ_REMOVE_HEAD(&config->entries, nodes);
+
+ // Free the entry
+ nw_config_entry_free(entry);
+ }
+
+ return 0;
+}
+
static int nw_config_parse(struct nw_config* config, FILE* f) {
// XXX TODO
struct nw_config* nw_config_ref(struct nw_config* config);
struct nw_config* nw_config_unref(struct nw_config* config);
+int nw_config_flush(struct nw_config* config);
+
int nw_config_readf(struct nw_config** config, FILE* f);
int nw_config_read(struct nw_config** config, const char* path);