chiark / gitweb /
cgroup: minor optimization
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Mar 2013 05:01:04 +0000 (06:01 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Mar 2013 14:46:49 +0000 (15:46 +0100)
src/core/cgroup.c

index 4790a09..8fb2952 100644 (file)
@@ -438,7 +438,7 @@ int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding)
                 return 1;
         }
 
                 return 1;
         }
 
-        p = strdup(cgroup);
+        p = strdupa(cgroup);
         if (!p)
                 return -ENOMEM;
 
         if (!p)
                 return -ENOMEM;
 
@@ -446,8 +446,7 @@ int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding)
                 char *e;
 
                 e = strrchr(p, '/');
                 char *e;
 
                 e = strrchr(p, '/');
-                if (!e || e == p) {
-                        free(p);
+                if (e == p || !e) {
                         *bonding = NULL;
                         return 0;
                 }
                         *bonding = NULL;
                         return 0;
                 }
@@ -456,7 +455,6 @@ int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding)
 
                 b = hashmap_get(m->cgroup_bondings, p);
                 if (b) {
 
                 b = hashmap_get(m->cgroup_bondings, p);
                 if (b) {
-                        free(p);
                         *bonding = b;
                         return 1;
                 }
                         *bonding = b;
                         return 1;
                 }