[Ocfs2-tools-devel] [PATCH 02/25] o2cb_config: Fix o2cb_config_free()

Sunil Mushran sunil.mushran at oracle.com
Wed Jun 23 11:44:12 PDT 2010


o2cb_config_free() now frees the list correctly.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 o2cb_ctl/o2cb_config.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/o2cb_ctl/o2cb_config.c b/o2cb_ctl/o2cb_config.c
index 24d733a..224c69d 100644
--- a/o2cb_ctl/o2cb_config.c
+++ b/o2cb_ctl/o2cb_config.c
@@ -593,22 +593,15 @@ static void o2cb_cluster_free(O2CBCluster *cluster)
     g_free(cluster);
 }  /* o2cb_cluster_free() */
 
-void o2cb_config_free(O2CBConfig *config)
+static void _o2cb_cluster_free(gpointer data, gpointer user_data)
 {
-    GList *list;
-    O2CBCluster *cluster;
-
-    while (config->co_clusters)
-    {
-        list = config->co_clusters;
-        config->co_clusters = list->next;
-
-        cluster = (O2CBCluster *)list->data;
-        g_list_free(list);
-
-        o2cb_cluster_free(cluster);
-    }
+	o2cb_cluster_free((O2CBCluster *)data);
+}
 
+void o2cb_config_free(O2CBConfig *config)
+{
+    g_list_foreach(config->co_clusters, _o2cb_cluster_free, NULL);
+    g_list_free(config->co_clusters);
     g_free(config);
 }
 
-- 
1.7.0.4




More information about the Ocfs2-tools-devel mailing list