]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Add cgroup_free_group_spec procedure
authorIvana Varekova <varekova@redhat.com>
Thu, 21 May 2009 10:06:20 +0000 (12:06 +0200)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Fri, 29 May 2009 10:20:15 +0000 (15:50 +0530)
Add cgroup_free_group_spec procedure which free cgroups_group_spec
variable.

Signed-off-by: Ivana Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
src/tools/tools-common.c
src/tools/tools-common.h

index b80ae3ca7b47eea7964e74f201f0e51714a9d03d..db46f6e885234e370bfd58821e37755199d51156 100644 (file)
@@ -86,3 +86,30 @@ int parse_cgroup_spec(struct cgroup_group_spec *cdptr[], char *optarg)
 
        return 0;
 }
+
+
+/**
+ * Free a single cgroup_group_spec structure
+ * <--->@param cl The structure to free from memory.
+ */
+void cgroup_free_group_spec(struct cgroup_group_spec *cl)
+{
+       /* Loop variable */
+       int i = 0;
+
+       /* Make sure our structure is not NULL, first. */
+       if (!cl) {
+               cgroup_dbg("Warning: Attempted to free NULL rule.\n");
+               return;
+       }
+
+       /* We must free any used controller strings, too. */
+       for (i = 0; i < CG_CONTROLLER_MAX; i++) {
+               if (cl->controllers[i])
+                       free(cl->controllers[i]);
+       }
+
+       free(cl);
+}
+
+
index 34379730781986a2f408fbce2fa1068a21f11e6b..65d87c76fb8b11a44d6c9da9a61e1ea5ab50ae44 100644 (file)
@@ -50,5 +50,10 @@ struct cgroup_group_spec {
  */
 int parse_cgroup_spec(struct cgroup_group_spec *cdptr[], char *optarg);
 
+/**
+ * Free a single cgroup_group_spec structure.
+ *     @param cl The structure to free from memory
+ */
+void cgroup_free_group_spec(struct cgroup_group_spec *cl);
 
 #endif /* TOOLS_COMMON */