Function rcutils_char_array_vsprintf

Function Documentation

rcutils_ret_t rcutils_char_array_vsprintf(rcutils_char_array_t *char_array, const char *format, va_list args)

Produce output according to format and args.

This function is equivalent to vsprintf(char_array->buffer, format, args) except that the buffer grows as needed so a user doesn’t have to deal with memory management. The va_list args will be cloned before being used, so a user can safely use it again after calling this function.

Parameters:
  • char_array[inout] pointer to the instance of rcutils_char_array_t which is being written to

  • format[in] the format string used by the underlying vsnprintf

  • args[in] the va_list used by the underlying vsnprintf

Returns:

RCUTILS_RET_OK if successful, or

Returns:

RCUTILS_RET_BAD_ALLOC if memory allocation failed, or

Returns:

RCUTILS_RET_ERROR if an unexpected error occurs.