chiark / gitweb /
strv: introduce new strv_from_stdarg_alloca() macro to generate a string array from...
[elogind.git] / src / shared / conf-files.c
index 6d99739353be97b0553059ffb0d205acff25459d..7ba4bee43bbc2efd091c405c6716f2335548eb53 100644 (file)
@@ -127,7 +127,7 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
                 return -ENOMEM;
         }
 
-        qsort(files, hashmap_size(fh), sizeof(char *), base_cmp);
+        qsort_safe(files, hashmap_size(fh), sizeof(char *), base_cmp);
         *strv = files;
 
         hashmap_free(fh);
@@ -148,18 +148,12 @@ int conf_files_list_strv(char ***strv, const char *suffix, const char *root, con
 }
 
 int conf_files_list(char ***strv, const char *suffix, const char *root, const char *dir, ...) {
-        _cleanup_strv_free_ char **dirs = NULL;
-        va_list ap;
+        char **dirs;
 
         assert(strv);
         assert(suffix);
 
-        va_start(ap, dir);
-        dirs = strv_new_ap(dir, ap);
-        va_end(ap);
-
-        if (!dirs)
-                return -ENOMEM;
+        dirs = strv_from_stdarg_alloca(dir);
 
         return conf_files_list_strv_internal(strv, suffix, root, dirs);
 }