mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-28 10:06:53 +02:00
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.
This commit is contained in:
parent
653d3e2c5d
commit
c8194ee3ec
@ -1588,7 +1588,7 @@ g_ascii_strup (const gchar *str,
|
|||||||
gboolean
|
gboolean
|
||||||
g_str_is_ascii (const gchar *str)
|
g_str_is_ascii (const gchar *str)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
|
|
||||||
for (i = 0; str[i]; i++)
|
for (i = 0; str[i]; i++)
|
||||||
if (str[i] & 0x80)
|
if (str[i] & 0x80)
|
||||||
@ -2518,7 +2518,7 @@ g_strfreev (gchar **str_array)
|
|||||||
{
|
{
|
||||||
if (str_array)
|
if (str_array)
|
||||||
{
|
{
|
||||||
int i;
|
gsize i;
|
||||||
|
|
||||||
for (i = 0; str_array[i] != NULL; i++)
|
for (i = 0; str_array[i] != NULL; i++)
|
||||||
g_free (str_array[i]);
|
g_free (str_array[i]);
|
||||||
@ -2543,7 +2543,7 @@ g_strdupv (gchar **str_array)
|
|||||||
{
|
{
|
||||||
if (str_array)
|
if (str_array)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
gchar **retval;
|
gchar **retval;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -2597,7 +2597,7 @@ g_strjoinv (const gchar *separator,
|
|||||||
|
|
||||||
if (*str_array)
|
if (*str_array)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
gsize len;
|
gsize len;
|
||||||
gsize separator_len;
|
gsize separator_len;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user