diff options
author | Ivana Varekova <varekova@redhat.com> | 2009-05-21 12:06:20 +0200 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-05-29 15:50:15 +0530 |
commit | 8279047b888cdc269c044d9ec5389def63620c9f (patch) | |
tree | 76173c2c0d6f2f9d68d7f33e0d9eea1b39375d67 /src | |
parent | 5c1a7d9e05a1ffa0740b6db1a85f55d54c761d1e (diff) | |
download | libcg-8279047b888cdc269c044d9ec5389def63620c9f.tar.gz libcg-8279047b888cdc269c044d9ec5389def63620c9f.tar.xz libcg-8279047b888cdc269c044d9ec5389def63620c9f.zip |
Add cgroup_free_group_spec procedure
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/tools-common.c | 27 | ||||
-rw-r--r-- | src/tools/tools-common.h | 5 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/tools/tools-common.c b/src/tools/tools-common.c index b80ae3c..db46f6e 100644 --- a/src/tools/tools-common.c +++ b/src/tools/tools-common.c @@ -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); +} + + diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h index 3437973..65d87c7 100644 --- a/src/tools/tools-common.h +++ b/src/tools/tools-common.h @@ -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 */ |