commit 53710532cd14d746fcfc42956b8512e390cdb63d
parent df53ae275f7ae14629198cc2a7e3881fcdf39be9
Author: wwp <wwp@free.fr>
Date: Thu, 24 May 2018 17:39:03 +0200
Since we depend on GLib 2.28, make real use of GList/GSList's _free_full
functions. Remove unused list freeing functions.
Diffstat:
8 files changed, 18 insertions(+), 47 deletions(-)
diff --git a/src/common/utils.c b/src/common/utils.c
@@ -134,32 +134,14 @@ GSList *slist_copy_deep(GSList *list, GCopyFunc func)
#endif
}
-void list_free_strings(GList *list)
+void list_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)
diff --git a/src/common/utils.h b/src/common/utils.h
@@ -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);
diff --git a/src/compose.c b/src/compose.c
@@ -11568,10 +11568,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;
@@ -11699,21 +11699,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;
}
diff --git a/src/folderview.c b/src/folderview.c
@@ -3132,10 +3132,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,
diff --git a/src/main.c b/src/main.c
@@ -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) {
diff --git a/src/messageview.c b/src/messageview.c
@@ -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)
diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c
@@ -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;
}
diff --git a/src/plugins/vcalendar/vcal_meeting_gtk.c b/src/plugins/vcalendar/vcal_meeting_gtk.c
@@ -1431,8 +1431,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();