]> git.ipfire.org Git - network.git/commitdiff
networkd: config: Split flushing all entries into a function
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Feb 2023 21:46:11 +0000 (21:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Feb 2023 21:46:11 +0000 (21:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/config.c
src/networkd/config.h

index b2a23f003d43f9bf6863650f9a9195d56c503d11..a11ee1cc583a84ac20bbf76c883edf687dd2a80d 100644 (file)
@@ -74,15 +74,8 @@ ERROR:
 }
 
 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);
 }
@@ -117,6 +110,20 @@ struct nw_config* nw_config_unref(struct nw_config* 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
 
index 3474ae13802b365a162e10327fe54ac502c9d6e9..38780631d5b579299b8771e672a3a753e37f1544 100644 (file)
@@ -33,6 +33,8 @@ int nw_config_create(struct nw_config** config);
 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);