Commit d4a59c28 authored by Peter Bloomfield's avatar Peter Bloomfield
Browse files

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
parent 84cef804
Pipeline #307502 passed with stage
in 35 seconds
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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 &&
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment