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

Sunil Mushran sunil.mushran at oracle.com
Tue Sep 14 15:54:32 PDT 2010


o2cb_config_free() now frees the list correctly.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
Signed-off-by: Joel Becker <joel.becker 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 328c118..4f86a36 100644
--- a/o2cb_ctl/o2cb_config.c
+++ b/o2cb_ctl/o2cb_config.c
@@ -597,22 +597,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