Function rcutils_char_array_memcpy

Function Documentation

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

Copy memory to buffer.

This function is equivalent to memcpy(char_array->buffer, src, n) except that the buffer grows as needed so a user doesn’t have to worry about overflow.

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

  • src[in] the memory to be copied from

  • n[in] a total of n bytes will be copied

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.