Basics
Guides
API Reference
Basics
Guides
API Reference
[17:7] extends: object
GStrvBuilder is a helper object to build a %NULL-terminated string arrays.
The following example shows how to build a two element array: c 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 }));
GStrvBuilder (Handle = null)
Creates a new #GStrvBuilder with a reference count of 1. Use g_strv_builder_unref() on the returned value when no longer needed.
Handle is an optional native handle or wrapper whose handle to adopt; when the native constructor is called.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.add (string value)
Add a string to the end of the array. Since 2.68
value is a string..None.add_many (list varargs)
Appends all the given strings to the builder. Since 2.70
... is one or more strings followed by %NULL.None.addv (list value)
Appends all the strings in the given vector to the builder. Since 2.70
value is the vector of strings to add.None.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.
the constructed string array. Since 2.68.ref ()
Atomically increments the reference count of @builder by one. This function is thread-safe and may be called from any thread.
The passed in #GStrvBuilder.take (string value)
Add a string to the end of the array. After @value belongs to the #GStrvBuilder and may no longer be modified by the caller. Since 2.80
value is a string. Ownership of the string is transferred to the #GStrvBuilder.None.unref ()
Decreases the reference count on @builder. In the event that there are no more references, releases all memory associated with the #GStrvBuilder.
None.unref_to_strv ()
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 useg_autoptr().c 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);
the constructed string array.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.