Method

GLibStrvBuilderunref_to_strv

unstable since: 2.82

Declaration

GStrv
g_strv_builder_unref_to_strv (
  GStrvBuilder* builder
)

Description

Decreases the reference count on the string vector builder, and returns its contents as a NULL-terminated string array.

This function is especially useful for cases where it’s not possible to use g_autoptr().

GStrvBuilder *builder = g_strv_builder_new ();
g_strv_builder_add (builder, "hello");
g_strv_builder_add (builder, "world");

GStrv array = g_strv_builder_unref_to_strv (builder);

g_assert_true (g_strv_equal (array, (const char *[]) { "hello", "world", NULL }));

g_strfreev (array);

Available since: 2.82

Return value

Type: An array of utf8

The constructed string array.

The array is NULL-terminated.
Each element is a NUL terminated UTF-8 string.