### Struct

# GLib StrvBuilder

since: 2.68

#### Description [src]

    struct GStrvBuilder {
      /* No available fields */
    }

`GStrvBuilder` is a helper object to build a `NULL`-terminated string arrays.

The following example shows how to build a two element array:

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

      g_auto(GStrv) array = g_strv_builder_end (builder);

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

Available since: 2.68

#### Constructors

###### g_strv_builder_new

Creates a new `GStrvBuilder` with a reference count of 1. Use `g_strv_builder_unref()` on the returned value when no longer needed.

since: 2.68

#### Instance methods

###### g_strv_builder_add

Add a string to the end of the array.

###### g_strv_builder_add_many

Appends all the given strings to the builder.

###### g_strv_builder_addv

Appends all the strings in the given vector to the builder.

###### g_strv_builder_end

Ends the builder process and returns the constructed NULL-terminated string array. The returned value should be freed with `g_strfreev()` when no longer needed.

###### g_strv_builder_ref

Atomically increments the reference count of `builder` by one. This function is thread-safe and may be called from any thread.

since: 2.68

###### g_strv_builder_take

Add a string to the end of the array. After `value` belongs to the `GStrvBuilder` and may no longer be modified by the caller.

###### g_strv_builder_unref

Decreases the reference count on `builder`.

since: 2.68

###### g_strv_builder_unref_to_strv

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

since: 2.82