[balsa] address: Use g_strv_length()



commit 9cae360c10b200d72b91b8c30e04863e8a98bc89
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Aug 18 10:53:39 2020 -0400

    address: Use g_strv_length()
    
    instead of implementing it ourselves.

 libbalsa/address.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 000bbaf9c..59bbb5319 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -744,9 +744,6 @@ libbalsa_address_set_edit_entries(LibBalsaAddress * address,
        if (*new_name != '\0') {
            names = g_strsplit(new_name, " ", 0);
 
-           for (cnt=0; names[cnt]; cnt++)
-               ;
-
            /* get first name */
            first_name = g_strdup(address->first_name
                                   ? address->first_name : names[0]);
@@ -755,10 +752,11 @@ libbalsa_address_set_edit_entries(LibBalsaAddress * address,
             if(address->last_name != NULL)
                 last_name = g_strdup(address->last_name);
             else {
-                if (cnt == 1)
+                guint n_names = g_strv_length(names);
+                if (n_names == 1)
                     last_name = g_strdup("");
                 else
-                    last_name = g_strdup(names[cnt - 1]);
+                    last_name = g_strdup(names[n_names - 1]);
             }
            g_strfreev(names);
        }


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