Function
GLibset_strv
unstable since: 2.90
Declaration [src]
static inline gboolean
g_set_strv (
char*** strv_pointer,
const char* const* new_strv
)
Description [src]
Safely replaces a string vector.
Updates a pointer to a NULL-terminated string array to a copy of new_strv
and returns whether the value was changed.
If new_strv matches the previous array, this function is a no-op. If
new_strv is different, a copy of it will be assigned to strv_pointer and
the previous array pointed to by strv_pointer will be freed with
g_strfreev().
The contents of both string arrays are compared for equality before replacing the value. In the worst case this requires O(N) time.
This function avoids a potential use-after-free when new_strv reuses
pointers from the original string array. This allows callers to build
a replacement array using existing strings without needing to copy
them beforehand.
strv_pointer must not be NULL, but can point to a NULL value.
Available since: 2.90
This function is not directly available to language bindings.
Parameters
strv_pointer-
Type:
char***A pointer to either a
NULL-terminated string array orNULL.The argument will be modified by the function. The caller of the function takes ownership of the returned data, and is responsible for freeing it. The value is a NUL terminated UTF-8 string. new_strv-
Type:
const char* const*A NULL-terminated string array to assign to
strv_pointer.The argument can be NULL.The data is owned by the caller of the function. The value is a NUL terminated UTF-8 string.