[glib] gstringchunk: Use g_slist_free_full() where possible



commit fabdf80c7de57e531fba70052a89ed19d3c24e91
Author: Christian Schramm <christian h m schramm gmail com>
Date:   Thu Jan 16 12:36:09 2014 +0100

    gstringchunk: Use g_slist_free_full() where possible
    
    We have that function, let's use it - instead of manually
    freeing the elements of the slist in a loop (and reduce
    the line count a bit).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722326

 glib/gstringchunk.c |   16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)
---
diff --git a/glib/gstringchunk.c b/glib/gstringchunk.c
index 1c40a48..359aeea 100644
--- a/glib/gstringchunk.c
+++ b/glib/gstringchunk.c
@@ -144,17 +144,10 @@ g_string_chunk_new (gsize size)
 void
 g_string_chunk_free (GStringChunk *chunk)
 {
-  GSList *tmp_list;
-
   g_return_if_fail (chunk != NULL);
 
   if (chunk->storage_list)
-    {
-      for (tmp_list = chunk->storage_list; tmp_list; tmp_list = tmp_list->next)
-        g_free (tmp_list->data);
-
-      g_slist_free (chunk->storage_list);
-    }
+    g_slist_free_full (chunk->storage_list, g_free);
 
   if (chunk->const_table)
     g_hash_table_destroy (chunk->const_table);
@@ -175,16 +168,11 @@ g_string_chunk_free (GStringChunk *chunk)
 void
 g_string_chunk_clear (GStringChunk *chunk)
 {
-  GSList *tmp_list;
-
   g_return_if_fail (chunk != NULL);
 
   if (chunk->storage_list)
     {
-      for (tmp_list = chunk->storage_list; tmp_list; tmp_list = tmp_list->next)
-        g_free (tmp_list->data);
-
-      g_slist_free (chunk->storage_list);
+      g_slist_free_full (chunk->storage_list, g_free);
 
       chunk->storage_list = NULL;
       chunk->storage_next = chunk->default_size;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]