[balsa/wip/gtk4] Use g_.*array_unref()
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4] Use g_.*array_unref()
- Date: Thu, 12 Jul 2018 15:45:20 +0000 (UTC)
commit f6ef84b92f75728746c7b6511c213b5ebec67766
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Jul 12 11:41:53 2018 -0400
Use g_.*array_unref()
instead of g_.*array_free(..., TRUE); also allows us to use
g_clear_pointer().
libbalsa/body.c | 2 +-
libbalsa/identity-widgets.c | 12 ++----------
libbalsa/mailbox.c | 28 +++++++++++++---------------
libbalsa/mailbox_imap.c | 14 ++++++--------
libbalsa/mailbox_local.c | 4 ++--
libbalsa/mailbox_maildir.c | 7 ++-----
libbalsa/mailbox_mbox.c | 8 ++++----
libbalsa/mailbox_mh.c | 12 +++++-------
libbalsa/message.c | 4 ++--
src/balsa-index.c | 7 ++++---
src/balsa-print-object-text.c | 2 +-
src/compose-window.c | 2 +-
src/filter-run-callbacks.c | 2 +-
src/mailbox-node.c | 2 +-
src/main-window.c | 2 +-
src/message-window.c | 2 +-
16 files changed, 47 insertions(+), 63 deletions(-)
---
diff --git a/libbalsa/body.c b/libbalsa/body.c
index 27656c0ba..37fac484c 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -658,7 +658,7 @@ libbalsa_message_body_get_content(LibBalsaMessageBody * body, gchar ** buf,
g_byte_array_append(array, &zero, 1);
*buf = (gchar *) g_byte_array_free(array, FALSE);
} else {
- g_byte_array_free(array, TRUE);
+ g_byte_array_unref(array);
g_set_error(err, LIBBALSA_MAILBOX_ERROR,
LIBBALSA_MAILBOX_ACCESS_ERROR,
"Write error in get_content");
diff --git a/libbalsa/identity-widgets.c b/libbalsa/identity-widgets.c
index 1160fc11e..01448a39a 100644
--- a/libbalsa/identity-widgets.c
+++ b/libbalsa/identity-widgets.c
@@ -393,7 +393,6 @@ static void ident_dialog_add_gpg_menu(GtkWidget * grid, gint row,
const gchar * menu_key);
static void add_show_menu(const char *label, gpointer data,
GtkWidget * menu);
-static void ident_dialog_free_values(GPtrArray * values);
static void display_frame_set_gpg_mode(GObject * dialog,
const gchar * key,
@@ -1659,7 +1658,7 @@ ident_dialog_add_gpg_menu(GtkWidget * grid, gint row, GtkDialog * dialog,
opt_menu = gtk_combo_box_text_new();
values = g_ptr_array_sized_new(3);
g_object_set_data_full(G_OBJECT(opt_menu), "identity-value", values,
- (GDestroyNotify) ident_dialog_free_values);
+ (GDestroyNotify) g_ptr_array_unref);
gtk_grid_attach(GTK_GRID(grid), opt_menu, 1, row, 1, 1);
g_object_set_data(G_OBJECT(dialog), menu_key, opt_menu);
@@ -1682,13 +1681,6 @@ add_show_menu(const char *label, gpointer data, GtkWidget * menu)
g_ptr_array_add(values, data);
}
-/* ident_dialog_free_values: helper function */
-static void
-ident_dialog_free_values(GPtrArray * values)
-{
- g_ptr_array_free(values, TRUE);
-}
-
static void
ident_dialog_add_smtp_menu(GtkWidget * grid, gint row, GtkDialog * dialog,
const gchar * label_name,
@@ -1707,7 +1699,7 @@ ident_dialog_add_smtp_menu(GtkWidget * grid, gint row, GtkDialog * dialog,
gtk_label_set_mnemonic_widget(GTK_LABEL(label), combo_box);
values = g_ptr_array_sized_new(g_slist_length(smtp_servers));
g_object_set_data_full(G_OBJECT(combo_box), "identity-value", values,
- (GDestroyNotify) ident_dialog_free_values);
+ (GDestroyNotify) g_ptr_array_unref);
gtk_grid_attach(GTK_GRID(grid), combo_box, 1, row, 1, 1);
g_object_set_data(G_OBJECT(dialog), menu_key, combo_box);
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 6ab56bb02..d76d319ee 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -304,16 +304,14 @@ libbalsa_mailbox_dispose(GObject *object)
g_signal_handlers_disconnect_by_func(mailbox,
lbm_get_index_entry_expunged_cb,
priv->msgnos_pending);
- g_array_free(priv->msgnos_pending, TRUE);
- priv->msgnos_pending = NULL;
+ g_clear_pointer(&priv->msgnos_pending, g_array_unref);
}
if (priv->msgnos_changed != NULL) {
g_signal_handlers_disconnect_by_func(mailbox,
lbm_msgno_changed_expunged_cb,
priv->msgnos_changed);
- g_array_free(priv->msgnos_changed, TRUE);
- priv->msgnos_changed = NULL;
+ g_clear_pointer(&priv->msgnos_changed, g_array_unref);
}
libbalsa_clear_source_id(&priv->changed_idle_id);
@@ -581,8 +579,7 @@ libbalsa_mailbox_free_mindex(LibBalsaMailbox *mailbox)
if (priv->mindex != NULL) {
g_ptr_array_foreach(priv->mindex, (GFunc) lbm_index_entry_free, NULL);
- g_ptr_array_free(priv->mindex, TRUE);
- priv->mindex = NULL;
+ g_clear_pointer(&priv->mindex, g_ptr_array_unref);
}
}
@@ -984,7 +981,7 @@ lbm_run_filters_on_reception_idle_cb(LibBalsaMailbox *mailbox)
libbalsa_mailbox_register_msgnos(mailbox, msgnos);
libbalsa_filter_mailbox_messages(filter, mailbox, msgnos);
libbalsa_mailbox_unregister_msgnos(mailbox, msgnos);
- g_array_free(msgnos, TRUE);
+ g_array_unref(msgnos);
}
libbalsa_progress_set_text(&progress, NULL, 0);
@@ -2370,7 +2367,7 @@ libbalsa_mailbox_msgno_change_flags(LibBalsaMailbox *mailbox,
libbalsa_mailbox_messages_change_flags(mailbox, msgnos, set,
clear);
libbalsa_mailbox_unregister_msgnos(mailbox, msgnos);
- g_array_free(msgnos, TRUE);
+ g_array_unref(msgnos);
return retval;
}
@@ -3938,8 +3935,8 @@ lbm_sort(LibBalsaMailbox *mbox,
}
if (sort_array->len <= 1) {
- g_array_free(sort_array, TRUE);
- g_ptr_array_free(node_array, TRUE);
+ g_array_unref(sort_array);
+ g_ptr_array_unref(node_array);
lbm_sort(mbox, node);
return;
}
@@ -4002,8 +3999,8 @@ lbm_sort(LibBalsaMailbox *mbox,
g_free(new_order);
}
- g_array_free(sort_array, TRUE);
- g_ptr_array_free(node_array, TRUE);
+ g_array_unref(sort_array);
+ g_ptr_array_unref(node_array);
for (tmp_node = node; tmp_node; tmp_node = tmp_node->next) {
lbm_sort(mbox, tmp_node);
@@ -4588,8 +4585,8 @@ lbm_try_reassemble(LibBalsaMailbox *mailbox,
}
g_ptr_array_foreach(partials, (GFunc) g_object_unref, NULL);
- g_ptr_array_free(partials, TRUE);
- g_array_free(messages, TRUE);
+ g_ptr_array_unref(partials);
+ g_array_unref(messages);
libbalsa_progress_set_text(&progress, NULL, 0);
}
@@ -4892,7 +4889,8 @@ libbalsa_mailbox_move_duplicates(LibBalsaMailbox *mailbox,
}
}
retval = msgnos->len;
- g_array_free(msgnos, TRUE);
+ g_array_unref(msgnos);
+
return retval;
}
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 7270ae20c..0759e3148 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -317,7 +317,7 @@ libbalsa_mailbox_imap_finalize(GObject *object)
g_assert(libbalsa_mailbox_get_open_ref(LIBBALSA_MAILBOX(mailbox)) == 0);
g_free(mailbox->path);
- g_array_free(mailbox->sort_ranks, TRUE);
+ g_array_unref(mailbox->sort_ranks);
g_list_free_full(mailbox->acls, (GDestroyNotify) imap_user_acl_free);
G_OBJECT_CLASS(libbalsa_mailbox_imap_parent_class)->finalize(object);
@@ -1241,10 +1241,8 @@ free_messages_info(LibBalsaMailboxImap *mbox)
g_free(msgid);
}
}
- g_array_free(mbox->messages_info, TRUE);
- mbox->messages_info = NULL;
- g_ptr_array_free(mbox->msgids, TRUE);
- mbox->msgids = NULL;
+ g_clear_pointer(&mbox->messages_info, g_array_unref);
+ g_clear_pointer(&mbox->msgids, g_ptr_array_unref);
}
@@ -3941,7 +3939,7 @@ static void
imap_cache_manager_free(struct ImapCacheManager *icm)
{
g_hash_table_destroy(icm->headers);
- g_array_free(icm->uidmap, TRUE);
+ g_array_unref(icm->uidmap);
g_free(icm);
}
@@ -4017,10 +4015,10 @@ icm_restore_from_cache(ImapMboxHandle *h,
rc = IMR_NO;
}
if (rc != IMR_OK) {
- g_array_free(uidmap, TRUE);
+ g_array_unref(uidmap);
return;
}
- g_array_free(icm->uidmap, TRUE);
+ g_array_unref(icm->uidmap);
icm->uidmap = uidmap;
/* printf("New uidmap has length: %u\n", icm->uidmap->len); */
}
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 0bbd2a3ec..0d2f9a34d 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -447,7 +447,7 @@ libbalsa_mailbox_local_finalize(GObject *object)
if (priv->threading_info != NULL) {
/* The memory owned by priv->threading_info was freed on closing,
* so we free only the array itself. */
- g_ptr_array_free(priv->threading_info, TRUE);
+ g_ptr_array_unref(priv->threading_info);
}
G_OBJECT_CLASS(libbalsa_mailbox_local_parent_class)->finalize(object);
@@ -625,7 +625,7 @@ lbm_local_save_tree(LibBalsaMailboxLocal *local)
filename, err->message);
g_error_free(err);
}
- g_array_free(save_info.array, TRUE);
+ g_array_unref(save_info.array);
g_free(filename);
}
diff --git a/libbalsa/mailbox_maildir.c b/libbalsa/mailbox_maildir.c
index ed01ab468..a177411ef 100644
--- a/libbalsa/mailbox_maildir.c
+++ b/libbalsa/mailbox_maildir.c
@@ -656,11 +656,8 @@ libbalsa_mailbox_maildir_close_mailbox(LibBalsaMailbox *mailbox,
}
/* Now it's safe to free the message info. */
- g_hash_table_destroy(mdir->messages_info);
- mdir->messages_info = NULL;
-
- g_ptr_array_free(mdir->msgno_2_msg_info, TRUE);
- mdir->msgno_2_msg_info = NULL;
+ g_clear_pointer(&mdir->messages_info, g_hash_table_destroy);
+ g_clear_pointer(&mdir->msgno_2_msg_info, g_ptr_array_unref);
}
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index a2da39544..6a879f317 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -436,7 +436,7 @@ lbm_mbox_save(LibBalsaMailboxMbox *mbox)
strerror(errno));
g_free(template);
g_free(filename);
- g_array_free(messages_info, TRUE);
+ g_array_unref(messages_info);
return;
}
if ((close(fd) != 0)
@@ -449,7 +449,7 @@ lbm_mbox_save(LibBalsaMailboxMbox *mbox)
}
g_free(template);
#endif /* !defined(__APPLE__) */
- g_array_free(messages_info, TRUE);
+ g_array_unref(messages_info);
} else if (unlink(filename) < 0) {
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Could not unlink file %s: %s"),
@@ -607,7 +607,7 @@ free_messages_info(GPtrArray *msgno_2_msg_info)
g_ptr_array_index(msgno_2_msg_info, i);
free_message_info(msg_info);
}
- g_ptr_array_free(msgno_2_msg_info, TRUE);
+ g_ptr_array_unref(msgno_2_msg_info);
}
@@ -1028,7 +1028,7 @@ lbm_mbox_check(LibBalsaMailbox *mailbox,
retval = lbm_mbox_check_file(mbox, &buffer, line);
}
- g_byte_array_free(line, TRUE);
+ g_byte_array_unref(line);
mbox_unlock(mailbox, buffer.stream);
g_object_unref(buffer.stream);
diff --git a/libbalsa/mailbox_mh.c b/libbalsa/mailbox_mh.c
index 628653f1a..707b5b0c5 100644
--- a/libbalsa/mailbox_mh.c
+++ b/libbalsa/mailbox_mh.c
@@ -506,7 +506,7 @@ lbm_mh_parse_sequences(LibBalsaMailboxMh *mailbox)
line->len = 0;
} while (!g_mime_stream_eos(gmime_stream_buffer));
g_object_unref(gmime_stream_buffer);
- g_byte_array_free(line, TRUE);
+ g_byte_array_unref(line);
}
@@ -636,7 +636,7 @@ lbm_mh_check(LibBalsaMailboxMh *mh,
} while (!g_mime_stream_eos(gmime_stream_buffer));
g_object_unref(gmime_stream_buffer);
- g_byte_array_free(line, TRUE);
+ g_byte_array_unref(line);
return retval;
}
@@ -760,8 +760,7 @@ libbalsa_mailbox_mh_close_mailbox(LibBalsaMailbox *mailbox,
libbalsa_mailbox_changed(mailbox);
}
- g_hash_table_destroy(mh->messages_info);
- mh->messages_info = NULL;
+ g_clear_pointer(&mh->messages_info, g_hash_table_destroy);
if (LIBBALSA_MAILBOX_CLASS(libbalsa_mailbox_mh_parent_class)->close_mailbox) {
LIBBALSA_MAILBOX_CLASS(libbalsa_mailbox_mh_parent_class)->close_mailbox(mailbox,
@@ -769,8 +768,7 @@ libbalsa_mailbox_mh_close_mailbox(LibBalsaMailbox *mailbox,
}
/* Now it's safe to free the message info. */
- g_ptr_array_free(mh->msgno_2_msg_info, TRUE);
- mh->msgno_2_msg_info = NULL;
+ g_clear_pointer(&mh->msgno_2_msg_info, g_ptr_array_unref);
}
@@ -1003,7 +1001,7 @@ libbalsa_mailbox_mh_sync(LibBalsaMailbox *mailbox,
}
} while (!g_mime_stream_eos(gmime_stream_buffer));
g_object_unref(gmime_stream_buffer);
- g_byte_array_free(line, TRUE);
+ g_byte_array_unref(line);
}
/* write sequences */
diff --git a/libbalsa/message.c b/libbalsa/message.c
index 0730e1ecc..02305af96 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -1367,7 +1367,7 @@ libbalsa_message_load_envelope_from_stream(LibBalsaMessage *message,
line->len = 0;
g_byte_array_append(line, &lookahead, 1);
} while (TRUE);
- g_byte_array_free(line, TRUE);
+ g_byte_array_unref(line);
g_object_unref(gmime_stream_buffer);
g_mime_stream_reset(gmime_stream);
@@ -1434,7 +1434,7 @@ libbalsa_message_copy(LibBalsaMessage *message,
g_array_append_val(msgnos, message->msgno);
retval =
libbalsa_mailbox_messages_copy(mailbox, msgnos, dest, err);
- g_array_free(msgnos, TRUE);
+ g_array_unref(msgnos);
} else {
GMimeStream *mime_stream = libbalsa_message_stream(message);
retval = libbalsa_mailbox_add_message(dest, mime_stream,
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 53e979b40..2b787bbc5 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -1575,7 +1575,7 @@ balsa_index_selected_msgnos_free(BalsaIndex *index,
mailbox = balsa_index_get_mailbox(index);
libbalsa_mailbox_unregister_msgnos(mailbox, msgnos);
- g_array_free(msgnos, TRUE);
+ g_array_unref(msgnos);
}
@@ -1839,7 +1839,7 @@ bndx_do_delete(BalsaIndex *index,
enable_empty_trash(balsa_app.main_window, TRASH_CHECK);
}
}
- g_array_free(messages, TRUE);
+ g_array_unref(messages);
balsa_index_selected_msgnos_free(index, selected);
}
@@ -2680,9 +2680,10 @@ bndx_pipe_queue_last(struct BndxPipeQueue *queue)
printf("Piping finished. Destroying the context.\n");
libbalsa_mailbox_unregister_msgnos(queue->mailbox, queue->msgnos);
libbalsa_mailbox_close(queue->mailbox, FALSE);
- g_array_free(queue->msgnos, TRUE);
+ g_array_unref(queue->msgnos);
g_free(queue->pipe_cmd);
g_free(queue);
+
return;
}
diff --git a/src/balsa-print-object-text.c b/src/balsa-print-object-text.c
index 8b25db41d..03bd89bef 100644
--- a/src/balsa-print-object-text.c
+++ b/src/balsa-print-object-text.c
@@ -292,7 +292,7 @@ balsa_print_object_text_plain(GList *list,
}
g_list_free_full(attr_list, g_free);
g_list_free(par_parts);
- g_array_free(attr_offs, TRUE);
+ g_array_unref(attr_offs);
}
/* clean up */
diff --git a/src/compose-window.c b/src/compose-window.c
index 661262521..2a333bb31 100644
--- a/src/compose-window.c
+++ b/src/compose-window.c
@@ -5838,7 +5838,7 @@ message_postpone(BalsaComposeWindow *compose_window)
compose_window->flow, &error);
}
g_ptr_array_foreach(headers, (GFunc) g_free, NULL);
- g_ptr_array_free(headers, TRUE);
+ g_ptr_array_unref(headers);
if (successp) {
sw_delete_draft(compose_window);
diff --git a/src/filter-run-callbacks.c b/src/filter-run-callbacks.c
index cf510fb56..f7b328a97 100644
--- a/src/filter-run-callbacks.c
+++ b/src/filter-run-callbacks.c
@@ -125,7 +125,7 @@ run_filters_on_mailbox(GSList * filters, LibBalsaMailbox * mbox)
sent_to_trash +=
libbalsa_filter_mailbox_messages(filter, mbox, messages);
libbalsa_mailbox_unregister_msgnos(mbox, messages);
- g_array_free(messages, TRUE);
+ g_array_unref(messages);
}
if (sent_to_trash)
diff --git a/src/mailbox-node.c b/src/mailbox-node.c
index 65e8ad8ca..4ce4f1ffd 100644
--- a/src/mailbox-node.c
+++ b/src/mailbox-node.c
@@ -289,7 +289,7 @@ balsa_mailbox_node_real_save_config(BalsaMailboxNode *mn,
libbalsa_conf_set_vector("Children", children_names->len,
(const char *const *)(children_names->pdata));
g_ptr_array_foreach(children_names, (GFunc)g_free, NULL);
- g_ptr_array_free(children_names, TRUE);
+ g_ptr_array_unref(children_names);
}
g_free(mn->config_prefix);
diff --git a/src/main-window.c b/src/main-window.c
index a78d6756e..0da3413fe 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -4148,7 +4148,7 @@ empty_trash(BalsaWindow * window)
libbalsa_mailbox_messages_change_flags(balsa_app.trash, messages,
LIBBALSA_MESSAGE_FLAG_DELETED,
0);
- g_array_free(messages, TRUE);
+ g_array_unref(messages);
/* We want to expunge deleted messages: */
libbalsa_mailbox_close(balsa_app.trash, TRUE);
diff --git a/src/message-window.c b/src/message-window.c
index 91d269d89..b9797a2ef 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -642,7 +642,7 @@ mw_move_message(BalsaMessageWindow * mw, LibBalsaMailbox * mailbox)
mw_set_selected(mw, balsa_index_select_next);
balsa_index_transfer(mw->bindex, messages, mailbox, FALSE);
- g_array_free(messages, TRUE);
+ g_array_unref(messages);
if (mw->message == original)
/* Either action-after-move was CLOSE, or we failed to select
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]