]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
locale-util: use string_hash_ops_free and set_to_strv()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Apr 2025 01:04:06 +0000 (10:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 12 Apr 2025 19:59:26 +0000 (04:59 +0900)
Then we can drop hackish combination of use of set_free_free() and
set_free().

src/basic/locale-util.c

index 2e4609b7fc4366fc70c832da09bb3fde391bcc78..2fbab01aebd058a91badcd565fb7380bc0e57110 100644 (file)
@@ -188,10 +188,10 @@ static int add_locales_from_libdir(Set *locales) {
 }
 
 int get_locales(char ***ret) {
-        _cleanup_set_free_free_ Set *locales = NULL;
+        _cleanup_set_free_ Set *locales = NULL;
         int r;
 
-        locales = set_new(&string_hash_ops);
+        locales = set_new(&string_hash_ops_free);
         if (!locales)
                 return -ENOMEM;
 
@@ -212,13 +212,10 @@ int get_locales(char ***ret) {
                         free(set_remove(locales, locale));
         }
 
-        _cleanup_strv_free_ char **l = set_get_strv(locales);
+        _cleanup_strv_free_ char **l = set_to_strv(&locales);
         if (!l)
                 return -ENOMEM;
 
-        /* Now, all elements are owned by strv 'l'. Hence, do not call set_free_free(). */
-        locales = set_free(locales);
-
         r = getenv_bool("SYSTEMD_LIST_NON_UTF8_LOCALES");
         if (r <= 0) {
                 if (!IN_SET(r, -ENXIO, 0))