diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt index 718ac6268..e7d68d5c7 100644 --- a/docs/reference/glib/glib-sections.txt +++ b/docs/reference/glib/glib-sections.txt @@ -1453,6 +1453,9 @@ g_strfreev g_strconcat g_strjoin g_strjoinv + + +GStrv g_strv_length g_strv_contains diff --git a/docs/reference/gobject/gobject-sections.txt b/docs/reference/gobject/gobject-sections.txt index b9f26c9a4..0f14f93fe 100644 --- a/docs/reference/gobject/gobject-sections.txt +++ b/docs/reference/gobject/gobject-sections.txt @@ -398,7 +398,6 @@ G_TYPE_SOURCE G_TYPE_POLLFD G_TYPE_THREAD G_TYPE_OPTION_GROUP -GStrv G_TYPE_IS_BOXED diff --git a/glib/docs.c b/glib/docs.c index d41899c7c..99531bce5 100644 --- a/glib/docs.c +++ b/glib/docs.c @@ -2343,8 +2343,10 @@ * { * g_auto(GQueue) queue = G_QUEUE_INIT; * g_auto(GVariantBuilder) builder; + * g_auto(GStrv) strv; * * g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + * strv = g_strsplit("a:b:c", ":", -1); * * ... * diff --git a/glib/glib-autocleanups.h b/glib/glib-autocleanups.h index f3929c0a0..6355f7565 100644 --- a/glib/glib-autocleanups.h +++ b/glib/glib-autocleanups.h @@ -86,3 +86,4 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantIter, g_variant_iter_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantDict, g_variant_dict_unref) G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantDict, g_variant_dict_clear) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantType, g_variant_type_free) +G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL) diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index dde612668..6712a64ff 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -2458,6 +2458,13 @@ g_strsplit_set (const gchar *string, return result; } +/** + * GStrv: + * + * A typedef alias for gchar**. This is mostly useful when used together with + * g_auto(). + */ + /** * g_strfreev: * @str_array: a %NULL-terminated array of strings to free diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h index 76004aae3..bc0c48e31 100644 --- a/glib/gstrfuncs.h +++ b/glib/gstrfuncs.h @@ -265,6 +265,7 @@ gpointer g_memdup (gconstpointer mem, * g_strdupv() copies a NULL-terminated array of strings * g_strv_length() returns the length of a NULL-terminated array of strings */ +typedef gchar** GStrv; GLIB_AVAILABLE_IN_ALL gchar** g_strsplit (const gchar *string, const gchar *delimiter, diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c index 6f0eafbf8..b44cf138b 100644 --- a/glib/tests/autoptr.c +++ b/glib/tests/autoptr.c @@ -398,6 +398,13 @@ test_g_variant_type (void) g_assert (val != NULL); } +static void +test_strv (void) +{ + g_auto(GStrv) val = g_strsplit("a:b:c", ":", -1); + g_assert (val != NULL); +} + int main (int argc, gchar *argv[]) { @@ -449,6 +456,7 @@ main (int argc, gchar *argv[]) g_test_add_func ("/autoptr/g_variant_iter", test_g_variant_iter); g_test_add_func ("/autoptr/g_variant_dict", test_g_variant_dict); g_test_add_func ("/autoptr/g_variant_type", test_g_variant_type); + g_test_add_func ("/autoptr/strv", test_strv); return g_test_run (); } diff --git a/gobject/glib-types.h b/gobject/glib-types.h index ac222b8b3..36d7e6efd 100644 --- a/gobject/glib-types.h +++ b/gobject/glib-types.h @@ -357,13 +357,6 @@ GType g_option_group_get_type (void) G_GNUC_CONST; GLIB_DEPRECATED_FOR('G_TYPE_VARIANT') GType g_variant_get_gtype (void) G_GNUC_CONST; -/** - * GStrv: - * - * A C representable type name for #G_TYPE_STRV. - */ -typedef gchar** GStrv; - G_END_DECLS #endif /* __GLIB_TYPES_H__ */ diff --git a/gobject/gobject-autocleanups.h b/gobject/gobject-autocleanups.h index 797f31534..980203f17 100644 --- a/gobject/gobject-autocleanups.h +++ b/gobject/gobject-autocleanups.h @@ -21,7 +21,6 @@ #error "Only can be included directly." #endif -G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref) G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset)