[balsa: 1/3] sendmsg-window: Use g_file_get_contents()




commit 0ee9f43d8e42eba8d3b333b5d21008ef87214c05
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue May 17 12:46:15 2022 -0400

    sendmsg-window: Use g_file_get_contents()
    
    to get the length of the contents, instead of needlessly using strlen().
    
    Thanks to @albrecht !
    https://gitlab.gnome.org/GNOME/balsa/-/merge_requests/59#note_1457564

 src/sendmsg-window.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 80c674fd1..47558dec1 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -683,7 +683,7 @@ edit_with_gnome_check(GPid     pid,
     char *filename = data_real->filename;
     GError *error = NULL;
     gchar *filebuf;
-    size_t filebuf_len;
+    gsize filebuf_len;
     gchar **lines, **line_p;
     GtkTextBuffer *buffer;
 
@@ -700,7 +700,7 @@ edit_with_gnome_check(GPid     pid,
         return;
     }
 
-    if (!g_file_get_contents(filename, &filebuf, NULL, &error)) {
+    if (!g_file_get_contents(filename, &filebuf, &filebuf_len, &error)) {
         balsa_information_parented(GTK_WINDOW(bsmsg->window),
                                    LIBBALSA_INFORMATION_WARNING,
                                    _("Cannot read the file ā€œ%sā€: %s"),
@@ -712,7 +712,6 @@ edit_with_gnome_check(GPid     pid,
         return;
     }
 
-    filebuf_len = strlen(filebuf);
     if (filebuf_len > 0) {
         /* Delete a trailing '\n' to avoid a last empty line from g_strsplit(). */
         gchar *last_char = &filebuf[filebuf_len - 1];


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