mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-12 02:35:28 +01:00
Add a function to calculate the length of a NULL-terminated string array.
Thu Sep 9 00:10:40 2004 Matthias Clasen <maclas@gmx.de> * glib/gstrfuncs.h: * glib/gstrfuncs.c (g_strv_length): Add a function to calculate the length of a NULL-terminated string array. (#150455, Tim-Philipp Müller) * tests/strfunc-test.c (main): Add a test for g_strv_length().
This commit is contained in:
parent
cbadee0812
commit
6ec4724399
@ -1,3 +1,12 @@
|
||||
Thu Sep 9 00:10:40 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/gstrfuncs.h:
|
||||
* glib/gstrfuncs.c (g_strv_length): Add a function to
|
||||
calculate the length of a NULL-terminated string
|
||||
array. (#150455, Tim-Philipp Müller)
|
||||
|
||||
* tests/strfunc-test.c (main): Add a test for g_strv_length().
|
||||
|
||||
2004-09-08 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gutils.c (guess_category_value): On Win32, as last resort
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Sep 9 00:10:40 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/gstrfuncs.h:
|
||||
* glib/gstrfuncs.c (g_strv_length): Add a function to
|
||||
calculate the length of a NULL-terminated string
|
||||
array. (#150455, Tim-Philipp Müller)
|
||||
|
||||
* tests/strfunc-test.c (main): Add a test for g_strv_length().
|
||||
|
||||
2004-09-08 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gutils.c (guess_category_value): On Win32, as last resort
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Sep 9 00:10:40 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/gstrfuncs.h:
|
||||
* glib/gstrfuncs.c (g_strv_length): Add a function to
|
||||
calculate the length of a NULL-terminated string
|
||||
array. (#150455, Tim-Philipp Müller)
|
||||
|
||||
* tests/strfunc-test.c (main): Add a test for g_strv_length().
|
||||
|
||||
2004-09-08 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gutils.c (guess_category_value): On Win32, as last resort
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Sep 9 00:10:40 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/gstrfuncs.h:
|
||||
* glib/gstrfuncs.c (g_strv_length): Add a function to
|
||||
calculate the length of a NULL-terminated string
|
||||
array. (#150455, Tim-Philipp Müller)
|
||||
|
||||
* tests/strfunc-test.c (main): Add a test for g_strv_length().
|
||||
|
||||
2004-09-08 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gutils.c (guess_category_value): On Win32, as last resort
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Sep 9 00:10:40 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/gstrfuncs.h:
|
||||
* glib/gstrfuncs.c (g_strv_length): Add a function to
|
||||
calculate the length of a NULL-terminated string
|
||||
array. (#150455, Tim-Philipp Müller)
|
||||
|
||||
* tests/strfunc-test.c (main): Add a test for g_strv_length().
|
||||
|
||||
2004-09-08 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gutils.c (guess_category_value): On Win32, as last resort
|
||||
|
@ -1,3 +1,7 @@
|
||||
Thu Sep 9 00:11:19 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib-sections.txt: Add g_strv_length().
|
||||
|
||||
2004-09-07 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/glib-sections.txt: Add g_get_language_names().
|
||||
|
@ -1085,6 +1085,7 @@ g_strfreev
|
||||
g_strconcat
|
||||
g_strjoin
|
||||
g_strjoinv
|
||||
g_strv_length
|
||||
|
||||
<SUBSECTION>
|
||||
g_strerror
|
||||
|
@ -2696,3 +2696,28 @@ g_strip_context (const gchar *msgid,
|
||||
|
||||
return msgval;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_strv_length:
|
||||
* @str_array: a %NULL-terminated array of strings.
|
||||
*
|
||||
* Returns the length of the given %NULL-terminated
|
||||
* string array @str_array.
|
||||
*
|
||||
* Return value: length of @str_array.
|
||||
*
|
||||
* Since: 2.6
|
||||
**/
|
||||
guint
|
||||
g_strv_length (gchar **str_array)
|
||||
{
|
||||
guint i = 0;
|
||||
|
||||
g_return_val_if_fail (str_array != NULL, 0);
|
||||
|
||||
while (str_array[i])
|
||||
++i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -219,6 +219,7 @@ gpointer g_memdup (gconstpointer mem,
|
||||
* optional separator, the returned string is newly allocated.
|
||||
* g_strfreev() frees the array itself and all of its strings.
|
||||
* g_strdupv() copies a NULL-terminated array of strings
|
||||
* g_strv_length() returns the length of a NULL-terminated array of strings
|
||||
*/
|
||||
gchar** g_strsplit (const gchar *string,
|
||||
const gchar *delimiter,
|
||||
@ -230,6 +231,7 @@ gchar* g_strjoinv (const gchar *separator,
|
||||
gchar **str_array);
|
||||
void g_strfreev (gchar **str_array);
|
||||
gchar** g_strdupv (gchar **str_array);
|
||||
guint g_strv_length (gchar **str_array);
|
||||
|
||||
gchar* g_stpcpy (gchar *dest,
|
||||
const char *src);
|
||||
|
@ -551,5 +551,7 @@ main (int argc,
|
||||
TEST (NULL, 9 == g_snprintf (buf, 5, "%s", "abcdefghi"));
|
||||
}
|
||||
|
||||
TEST (NULL, g_strv_length (g_strsplit ("1,2,3,4", ",", -1)) == 4);
|
||||
|
||||
return any_failed;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user