Function rcutils_char_array_init

Function Documentation

rcutils_ret_t rcutils_char_array_init(rcutils_char_array_t *char_array, size_t buffer_capacity, const rcutils_allocator_t *allocator)

Initialize a zero initialized char array struct.

This function may leak if the char array struct is already pre-initialized. If the capacity is set to 0, no memory is allocated and the internal buffer is still NULL.

Parameters:
  • char_array[in] a pointer to the to be initialized char array struct

  • buffer_capacity[in] the size of the memory to allocate for the byte stream

  • allocator[in] the allocator to use for the memory allocation

Returns:

RCUTILS_RET_OK if successful, or

Returns:

RCUTILS_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCUTILS_RET_BAD_ALLOC if no memory could be allocated correctly

Returns:

RCUTILS_RET_ERROR if an unexpected error occurs.