]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce hashmap_find_free_section_line()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Oct 2020 13:16:46 +0000 (22:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:44:43 +0000 (02:44 +0900)
src/network/networkd-util.c
src/network/networkd-util.h

index ce9319d942a3aa450fe438484d7e5cbd1d2cbde8..bae4ee5cbacf1ac2174eeb44d9880054c34d3883 100644 (file)
@@ -151,3 +151,15 @@ int network_config_section_new(const char *filename, unsigned line, NetworkConfi
 void network_config_section_free(NetworkConfigSection *cs) {
         free(cs);
 }
+
+unsigned hashmap_find_free_section_line(Hashmap *hashmap) {
+        NetworkConfigSection *cs;
+        unsigned n = 0;
+        void *entry;
+
+        HASHMAP_FOREACH_KEY(entry, cs, hashmap)
+                if (n < cs->line)
+                        n = cs->line;
+
+        return n + 1;
+}
index 2b6541d57edf2febd1076cc2f51741961a2deaea..ce169fa731b4b0d50973d6589847df137fc3d69e 100644 (file)
@@ -5,7 +5,7 @@
 #include "sd-netlink.h"
 
 #include "conf-parser.h"
-#include "hash-funcs.h"
+#include "hashmap.h"
 #include "log.h"
 #include "macro.h"
 #include "string-util.h"
@@ -52,6 +52,7 @@ int network_config_section_new(const char *filename, unsigned line, NetworkConfi
 void network_config_section_free(NetworkConfigSection *network);
 DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection*, network_config_section_free);
 extern const struct hash_ops network_config_hash_ops;
+unsigned hashmap_find_free_section_line(Hashmap *hashmap);
 
 static inline bool section_is_invalid(NetworkConfigSection *section) {
         /* If this returns false, then it does _not_ mean the section is valid. */