From: Christian Schramm Date: Thu, 16 Jan 2014 11:36:09 +0000 (+0100) Subject: gstringchunk: Use g_slist_free_full() where possible X-Git-Tag: 2.39.4~129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fabdf80c7de57e531fba70052a89ed19d3c24e91;p=platform%2Fupstream%2Fglib.git 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 --- 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;