cgroup_{reload|init}_cached_templates does not free memory if no template
is set. This patch fix the problem.

Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com>
---

 src/config.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/config.c b/src/config.c
index 7240ec1..57703dc 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1468,7 +1468,7 @@ int cgroup_reload_cached_templates(char *pathname)
        }
        template_table_index = 0;
 
-       if (config_template_table_index != 0) {
+       if ((config_template_table_index != 0) || (config_table_index != 0)) {
                /* config template structures have to be free as well*/
                cgroup_free_config();
        }
@@ -1523,7 +1523,16 @@ int cgroup_init_templates_cache(char *pathname)
        int ret = 0;
        int i;
 
-       if (config_template_table_index != 0) {
+       if (template_table) {
+               /* template structures have to be free */
+               for (i = 0; i < template_table_index; i++)
+                       cgroup_free_controllers(&template_table[i]);
+               free(template_table);
+               template_table = NULL;
+       }
+       template_table_index = 0;
+
+       if ((config_template_table_index != 0) || (config_table_index != 0)) {
                /* config structures have to be clean */
                cgroup_free_config();
        }


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to