[balsa] Various: Use g_array_set_size()



commit d4a59c2875f5fb040cb38bd51918a98dfd2a5afb
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Fri Aug 13 14:58:58 2021 -0400

    Various: Use g_array_set_size()
    
    to set the size of a GArray, and similarly GByteArray.
    
    Simply assigning a value to array->len works when shortening an array
    with no free-function, but the doc says:
    "To set the size of an array, use g_array_set_size()."
    
    modified:   libbalsa/mailbox.c
    modified:   libbalsa/mailbox_imap.c
    modified:   libbalsa/mailbox_mbox.c
    modified:   libbalsa/mailbox_mh.c
    modified:   libbalsa/message.c

 libbalsa/mailbox.c      | 6 +++---
 libbalsa/mailbox_imap.c | 2 +-
 libbalsa/mailbox_mbox.c | 3 +--
 libbalsa/mailbox_mh.c   | 6 +++---
 libbalsa/message.c      | 2 +-
 5 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index cc429db6c..2619a38e9 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -1328,7 +1328,7 @@ lbm_msgnos_changed_idle_cb(LibBalsaMailbox * mailbox)
 
     g_debug("%s %s %d processed", __func__, priv->name,
             priv->msgnos_changed->len);
-    priv->msgnos_changed->len = 0;
+    g_array_set_size(priv->msgnos_changed, 0);
     g_mutex_unlock(&msgnos_changed_lock);
 
     g_object_unref(mailbox);
@@ -3152,7 +3152,7 @@ lbm_get_index_entry_real(LibBalsaMailbox * mailbox)
 
     g_debug("%s %s %d processed", __func__, priv->name,
             priv->msgnos_pending->len);
-    priv->msgnos_pending->len = 0;
+    g_array_set_size(priv->msgnos_pending, 0);
     g_mutex_unlock(&get_index_entry_lock);
 
     g_object_unref(mailbox);
@@ -4437,7 +4437,7 @@ lbm_update_msgnos(LibBalsaMailbox * mailbox, guint seqno, GArray * msgnos)
         g_array_index(msgnos, guint, j) = msgno;
         ++j;
     }
-    msgnos->len = j;
+    g_array_set_size(msgnos, j);
 }
 
 void
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 58a80c08a..2d49aef07 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -3610,7 +3610,7 @@ icm_restore_from_cache(ImapMboxHandle *h, struct ImapCacheManager *icm)
                "- syncing uid map for msgno [%u:%u].",
                icm->exists, exists, icm->uidnext, uidnext, lo, hi);
         if(k) {
-            uidmap->len = lo-1;
+            g_array_set_size(uidmap, lo-1);
             rc = imap_search_exec(h, TRUE, k, set_uid, uidmap);
             imap_search_key_free(k);
         } else rc = IMR_NO;
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index 8ce8839a7..ff442a046 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -745,7 +745,7 @@ lbm_mbox_readln(LbmMboxStreamBuffer * buffer, GByteArray * line)
 {
     gchar *p, *q, *r;
 
-    line->len = 0;
+    g_byte_array_set_size(line, 0);
 
     do {
         if (buffer->start >= buffer->end) {
@@ -1697,7 +1697,6 @@ libbalsa_mailbox_mbox_sync(LibBalsaMailbox * mailbox, gboolean expunge)
        j++;
     }
     libbalsa_mime_stream_shared_unlock(mbox_stream);
-    mbox->msgno_2_msg_info->len = j;
     g_object_unref(gmime_parser);
     lbm_mbox_save(mbox);
 
diff --git a/libbalsa/mailbox_mh.c b/libbalsa/mailbox_mh.c
index 765afba6d..25d031e13 100644
--- a/libbalsa/mailbox_mh.c
+++ b/libbalsa/mailbox_mh.c
@@ -459,11 +459,11 @@ lbm_mh_parse_sequences(LibBalsaMailboxMh * mailbox)
     g_object_unref(gmime_stream);
     line = g_byte_array_new();
     do {
+       g_byte_array_set_size(line, 0);
        g_mime_stream_buffer_readln(gmime_stream_buffer, line);
        g_byte_array_append(line, zero, 1);
 
        lbm_mh_handle_seq_line(mailbox, (gchar *) line->data);
-       line->len = 0;
     } while (!g_mime_stream_eos(gmime_stream_buffer));
     g_object_unref(gmime_stream_buffer);
     g_byte_array_free(line, TRUE);
@@ -544,7 +544,7 @@ lbm_mh_check(LibBalsaMailboxMh * mh, const gchar * path)
 
     line = g_byte_array_new();
     do {
-       line->len = 0;
+       g_byte_array_set_size(line, 0);
        g_mime_stream_buffer_readln(gmime_stream_buffer, line);
        g_byte_array_append(line, zero, 1);
 
@@ -904,7 +904,7 @@ libbalsa_mailbox_mh_sync(LibBalsaMailbox * mailbox, gboolean expunge)
         do {
             gchar *buf;
 
-            line->len = 0;
+            g_byte_array_set_size(line, 0);
             g_mime_stream_buffer_readln(gmime_stream_buffer, line);
             buf = (gchar *) line->data;
             if (buf &&
diff --git a/libbalsa/message.c b/libbalsa/message.c
index 260dea9da..20aa4c0d8 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -1415,7 +1415,7 @@ libbalsa_message_load_envelope_from_stream(LibBalsaMessage *message,
             message->length = g_mime_stream_length(gmime_stream);
             break;
         }
-        line->len = 0;
+        g_byte_array_set_size(line, 0);
         g_byte_array_append(line, &lookahead, 1);
     } while (TRUE);
     g_byte_array_free(line, TRUE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]