[glib: 1/2] gstrfuncs: use gsize type internally for strv functions



commit c8194ee3eceac762983d7aec6e716f9f5297001b
Author: Thomas Haller <thaller redhat com>
Date:   Thu Nov 21 08:24:53 2019 +0100

    gstrfuncs: use gsize type internally for strv functions
    
    In C, the proper type for a heap allocate structure is size_t/gsize.
    That means, no valid (heap allocated) pointer will ever contain more
    bytes than size_t can represent.
    
    Hence, this integer type should also be used when operating on
    data like a strv array. Adjust some internal uses to use gsize
    instead of gint/guint.
    
    Note that g_strv_length() returns a value of type guint. So this
    API cannot be used on string arrays longer of arbitrary size. But
    that is not fixable.

 glib/gstrfuncs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index 57aec6823..f34aca29d 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -1588,7 +1588,7 @@ g_ascii_strup (const gchar *str,
 gboolean
 g_str_is_ascii (const gchar *str)
 {
-  gint i;
+  gsize i;
 
   for (i = 0; str[i]; i++)
     if (str[i] & 0x80)
@@ -2518,7 +2518,7 @@ g_strfreev (gchar **str_array)
 {
   if (str_array)
     {
-      int i;
+      gsize i;
 
       for (i = 0; str_array[i] != NULL; i++)
         g_free (str_array[i]);
@@ -2543,7 +2543,7 @@ g_strdupv (gchar **str_array)
 {
   if (str_array)
     {
-      gint i;
+      gsize i;
       gchar **retval;
 
       i = 0;
@@ -2597,7 +2597,7 @@ g_strjoinv (const gchar  *separator,
 
   if (*str_array)
     {
-      gint i;
+      gsize i;
       gsize len;
       gsize separator_len;
 


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