[balsa] mailbox: Use g_ptr_array_new_with_free_func()
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] mailbox: Use g_ptr_array_new_with_free_func()
- Date: Thu, 2 May 2019 01:51:38 +0000 (UTC)
commit bdd52e14bf4467c413b049eccf23f9ba63471dc4
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Wed May 1 21:13:33 2019 -0400
mailbox: Use g_ptr_array_new_with_free_func()
mailbox: Use g_ptr_array_new_with_free_func() to manage
deallocation of LibBalsaMailboxIndexEntry.
* libbalsa/mailbox.c (lbm_index_entry_free),
(libbalsa_mailbox_free_mindex), (libbalsa_mailbox_open),
(libbalsa_mailbox_msgno_removed)
ChangeLog | 9 +++++++++
libbalsa/mailbox.c | 16 +++++-----------
2 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cf854ff05..143d0d320 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-05-01 Peter Bloomfield <pbloomfield bellsouth net>
+
+ mailbox: Use g_ptr_array_new_with_free_func() to manage
+ deallocation of LibBalsaMailboxIndexEntry.
+
+ * libbalsa/mailbox.c (lbm_index_entry_free),
+ (libbalsa_mailbox_free_mindex), (libbalsa_mailbox_open),
+ (libbalsa_mailbox_msgno_removed)
+
2019-05-01 Peter Bloomfield <pbloomfield bellsouth net>
mailbox-mbox: Use g_ptr_array_new_with_free_func() to manage
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 10f177cb7..b15eeee8f 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -370,7 +370,7 @@ lbm_index_entry_new_pending(void)
static void
lbm_index_entry_free(LibBalsaMailboxIndexEntry *entry)
{
- if(entry) {
+ if (entry != NULL) {
if (!entry->idle_pending)
{
g_free(entry->from);
@@ -559,11 +559,7 @@ libbalsa_mailbox_new_from_config(const gchar * group, gboolean is_special)
static void
libbalsa_mailbox_free_mindex(LibBalsaMailbox *mailbox)
{
- if(mailbox->mindex) {
- unsigned i;
- /* we could have used g_ptr_array_foreach but it is >=2.4.0 */
- for(i=0; i<mailbox->mindex->len; i++)
- lbm_index_entry_free(g_ptr_array_index(mailbox->mindex, i));
+ if (mailbox->mindex != NULL) {
g_ptr_array_free(mailbox->mindex, TRUE);
mailbox->mindex = NULL;
}
@@ -590,7 +586,8 @@ libbalsa_mailbox_open(LibBalsaMailbox * mailbox, GError **err)
mailbox->stamp++;
if(mailbox->mindex) g_warning("mindex set - I leak memory");
- mailbox->mindex = g_ptr_array_new();
+ mailbox->mindex =
+ g_ptr_array_new_with_free_func((GDestroyNotify) lbm_index_entry_free);
saved_state = mailbox->state;
mailbox->state = LB_MAILBOX_STATE_OPENING;
@@ -1446,11 +1443,8 @@ libbalsa_mailbox_msgno_removed(LibBalsaMailbox * mailbox, guint seqno)
g_node_traverse(mailbox->msg_tree, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
decrease_post, &dt);
- if (seqno <= mailbox->mindex->len) {
- lbm_index_entry_free(g_ptr_array_index(mailbox->mindex,
- seqno - 1));
+ if (seqno <= mailbox->mindex->len)
g_ptr_array_remove_index(mailbox->mindex, seqno - 1);
- }
mailbox->msg_tree_changed = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]