locale-util: use string_hash_ops_free and set_to_strv()

Then we can drop hackish combination of use of set_free_free() and
set_free().
This commit is contained in:
Yu Watanabe
2025-04-13 04:59:26 +09:00
parent 3f23b37c5a
commit 21d84e8905
+3 -6
View 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))