chiark / gitweb /
util: use join() instead of asprintf() as an optimization
[elogind.git] / src / load-dropin.c
index d30865cbc53789a5442d9fa76e2efab49c1ce893..dbdc6a41df9a35ab09d133721cf60c23296e0d56 100644 (file)
@@ -50,7 +50,8 @@ static int iterate_dir(Unit *u, const char *path, UnitDependency dependency) {
                 if (ignore_file(de->d_name))
                         continue;
 
-                if (asprintf(&f, "%s/%s", path, de->d_name) < 0) {
+                f = join(path, "/", de->d_name, NULL);
+                if (!f) {
                         r = -ENOMEM;
                         goto finish;
                 }
@@ -78,7 +79,8 @@ static int process_dir(Unit *u, const char *unit_path, const char *name, const c
         assert(name);
         assert(suffix);
 
-        if (asprintf(&path, "%s/%s%s", unit_path, name, suffix) < 0)
+        path = join(unit_path, "/", name, suffix, NULL);
+        if (!path)
                 return -ENOMEM;
 
         if (u->meta.manager->unit_path_cache &&