Function

GLibstrdup_vprintf

Declaration

gchar*
g_strdup_vprintf (
  const gchar* format,
  va_list args
)

Description

Similar to the standard C vsprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result.

The returned string is guaranteed to be non-NULL, unless format contains %lc or %ls conversions, which can fail if no multibyte representation is available for the given character.

See also g_vasprintf(), which offers the same functionality, but additionally returns the length of the allocated string.

This function is not directly available to language bindings.

Parameters

format

Type: const gchar*

A standard printf() format string, but notice string precision pitfalls

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
args

Type: va_list

The list of parameters to insert into the format string.

Return value

Type: gchar*

A newly-allocated string holding the result.

The caller of the function takes ownership of the data, and is responsible for freeing it.
The return value can be NULL.
The value is a NUL terminated UTF-8 string.