Since we depend on GLib 2.28, make real use of GList/GSList's _free_full
authorwwp <wwp@free.fr>
Thu, 24 May 2018 15:39:03 +0000 (17:39 +0200)
committerwwp <wwp@free.fr>
Thu, 24 May 2018 15:39:03 +0000 (17:39 +0200)
functions. Remove unused list freeing functions.

src/common/utils.c
src/common/utils.h
src/compose.c
src/folderview.c
src/main.c
src/messageview.c
src/plugins/vcalendar/vcal_folder.c
src/plugins/vcalendar/vcal_meeting_gtk.c

index 6bb2d6f..17dcabb 100644 (file)
@@ -134,32 +134,14 @@ GSList *slist_copy_deep(GSList *list, GCopyFunc func)
 #endif
 }
 
-void list_free_strings(GList *list)
+void slist_free_strings_full(GList *list)
 {
-       list = g_list_first(list);
-
-       while (list != NULL) {
-               g_free(list->data);
-               list = list->next;
-       }
-}
-
-void slist_free_strings(GSList *list)
-{
-       while (list != NULL) {
-               g_free(list->data);
-               list = list->next;
-       }
+       g_list_free_full(list, (GDestroyNotify)g_free);
 }
 
 void slist_free_strings_full(GSList *list)
 {
-#if GLIB_CHECK_VERSION(2,28,0)
        g_slist_free_full(list, (GDestroyNotify)g_free);
-#else
-       g_slist_foreach(list, (GFunc)g_free, NULL);
-       g_slist_free(list);
-#endif
 }
 
 static void hash_free_strings_func(gpointer key, gpointer value, gpointer data)
index c904874..b3c088c 100644 (file)
@@ -278,8 +278,7 @@ GSList *slist_copy_deep             (GSList         *list,
 
 /* String utilities.  */
 
-void list_free_strings         (GList          *list);
-void slist_free_strings                (GSList         *list);
+void list_free_strings_full            (GList          *list);
 void slist_free_strings_full   (GSList         *list);
 
 void hash_free_strings         (GHashTable     *table);
index 7888cd4..5583ba4 100644 (file)
@@ -11552,10 +11552,10 @@ static void compose_attach_drag_received_cb (GtkWidget                *widget,
                                 utf8_filename, NULL, NULL);
                        g_free(utf8_filename);
                }
-               if (list) compose_changed_cb(NULL, compose);
-               list_free_strings(list);
-               g_list_free(list);
-       } else if (gtk_drag_get_source_widget(context) 
+               if (list)
+                       compose_changed_cb(NULL, compose);
+               list_free_strings_full(list);
+       } else if (gtk_drag_get_source_widget(context)
                   == summary_get_main_widget(mainwindow_get_mainwindow()->summaryview)) {
                /* comes from our summaryview */
                SummaryView * summaryview = NULL;
@@ -11683,21 +11683,18 @@ static void compose_insert_drag_received_cb (GtkWidget                *widget,
 
                if (val == G_ALERTDEFAULT || val == G_ALERTCANCEL) {
                        gtk_drag_finish(drag_context, FALSE, FALSE, time);
-                       list_free_strings(list);
-                       g_list_free(list);
+                       list_free_strings_full(list);
                        return;
                } else if (val == G_ALERTOTHER) {
                        compose_attach_drag_received_cb(widget, drag_context, x, y, data, info, time, user_data);
-                       list_free_strings(list);
-                       g_list_free(list);
+                       list_free_strings_full(list);
                        return;
                } 
 
                for (tmp = list; tmp != NULL; tmp = tmp->next) {
                        compose_insert_file(compose, (const gchar *)tmp->data);
                }
-               list_free_strings(list);
-               g_list_free(list);
+               list_free_strings_full(list);
                gtk_drag_finish(drag_context, TRUE, FALSE, time);
                return;
        }
index ae53b90..8c19b19 100644 (file)
@@ -3138,10 +3138,9 @@ void folderview_finish_dnd(const gchar *data, GdkDragContext *drag_context,
                g_slist_free(msglist);
                gtk_drag_finish(drag_context, TRUE, FALSE, time);
        } else {
-               gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+               gtk_drag_finish(drag_context, FALSE, FALSE, time);
        }
-       list_free_strings(list);
-       g_list_free(list);
+       list_free_strings_full(list);
 }
 
 static void folderview_drag_received_cb(GtkWidget        *widget,
index c9590a7..22baeb4 100644 (file)
@@ -1585,8 +1585,7 @@ int main(int argc, char *argv[])
                open_compose_new(cmd.compose_mailto, cmd.attach_files);
        }
        if (cmd.attach_files) {
-               list_free_strings(cmd.attach_files);
-               g_list_free(cmd.attach_files);
+               list_free_strings_full(cmd.attach_files);
                cmd.attach_files = NULL;
        }
        if (cmd.subscribe) {
index 95d851f..558ab6b 100644 (file)
@@ -1195,11 +1195,9 @@ static void messageview_register_nav(MessageView *messageview)
                        if (end->prev) {
                                end->prev->next = NULL;
                                end->prev = NULL;
-                               list_free_strings(end);
-                               g_list_free(end);
+                               list_free_strings_full(end);
                        } else {
-                               list_free_strings(messageview->trail);
-                               g_list_free(messageview->trail);
+                               list_free_strings_full(messageview->trail);
                                messageview->trail = NULL;
                        }
                }
@@ -1656,8 +1654,7 @@ void messageview_destroy(MessageView *messageview)
                g_free(messageview->toolbar);
        }
 
-       list_free_strings(messageview->trail);
-       g_list_free(messageview->trail);
+       list_free_strings_full(messageview->trail);
        msgview_list = g_list_remove(msgview_list, messageview); 
 
        if (messageview->window)
index 1c987bd..d4217a1 100644 (file)
@@ -1531,8 +1531,7 @@ gchar* get_item_event_list_for_date(FolderItem *item, EventTime date)
                        strcpy(result+e_len+2, (gchar *)cur->data);
                }
        }
-       slist_free_strings(strs);
-       g_slist_free(strs);
+       slist_free_strings_full(strs);
        return result;
 }
 
index 967ac8c..5b2dc26 100644 (file)
@@ -1418,8 +1418,7 @@ static VCalMeeting *vcal_meeting_create_real(VCalEvent *event, gboolean visible)
        gtk_combo_box_set_active(GTK_COMBO_BOX(meet->end_time), -1);
        combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(meet->end_time), times);
 
-       list_free_strings(times);
-       g_list_free(times);
+       list_free_strings_full(times);
 
        meet->location          = gtk_entry_new();
        meet->summary           = gtk_entry_new();