]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: introduce ordered_hashmap_by_section_find_unused_line() 29123/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 7 Sep 2023 19:42:48 +0000 (04:42 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 8 Sep 2023 03:55:44 +0000 (12:55 +0900)
src/shared/conf-parser.c
src/shared/conf-parser.h

index 7d51927845432868db9960f759be8edc2a8bd1d4..63030d4a2d0d6c8de3d6e6039f1d39ec2459ab83 100644 (file)
@@ -766,8 +766,8 @@ int config_section_new(const char *filename, unsigned line, ConfigSection **ret)
         return 0;
 }
 
-int hashmap_by_section_find_unused_line(
-                Hashmap *entries_by_section,
+int _hashmap_by_section_find_unused_line(
+                HashmapBase *entries_by_section,
                 const char *filename,
                 unsigned *ret) {
 
@@ -775,7 +775,7 @@ int hashmap_by_section_find_unused_line(
         unsigned n = 0;
         void *entry;
 
-        HASHMAP_FOREACH_KEY(entry, cs, entries_by_section) {
+        HASHMAP_BASE_FOREACH_KEY(entry, cs, entries_by_section) {
                 if (filename && !streq(cs->filename, filename))
                         continue;
                 n = MAX(n, cs->line);
index 74943523b346e57b98619f0594101e5b71c57b6c..140883969cc19ab3dd89b33421783f3e66906a61 100644 (file)
@@ -138,10 +138,22 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(ConfigSection*, config_section_free);
 
 int config_section_new(const char *filename, unsigned line, ConfigSection **ret);
 extern const struct hash_ops config_section_hash_ops;
-int hashmap_by_section_find_unused_line(
-                Hashmap *entries_by_section,
+int _hashmap_by_section_find_unused_line(
+                HashmapBase *entries_by_section,
                 const char *filename,
                 unsigned *ret);
+static inline int hashmap_by_section_find_unused_line(
+                Hashmap *entries_by_section,
+                const char *filename,
+                unsigned *ret) {
+        return _hashmap_by_section_find_unused_line(HASHMAP_BASE(entries_by_section), filename, ret);
+}
+static inline int ordered_hashmap_by_section_find_unused_line(
+                OrderedHashmap *entries_by_section,
+                const char *filename,
+                unsigned *ret) {
+        return _hashmap_by_section_find_unused_line(HASHMAP_BASE(entries_by_section), filename, ret);
+}
 
 static inline bool section_is_invalid(ConfigSection *section) {
         /* If this returns false, then it does _not_ mean the section is valid. */