Function rcutils_char_array_strncat

Function Documentation

rcutils_ret_t rcutils_char_array_strncat(rcutils_char_array_t *char_array, const char *src, size_t n)

Append a string (or part of it) to the string in buffer.

This function treats the internal buffer as a string and appends the src string to it. If src is longer than n, n bytes will be used and an extra null byte will be appended. It is virtually equivalent to strncat(char_array->buffer, src, n) except that the buffer grows as needed so a user doesn’t have to deal with memory management.

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

  • src[in] the string to be appended to the end of the string in buffer

  • n[in] it uses at most n bytes from the src string

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.