Function rcutils_string_array_resize

Function Documentation

rcutils_ret_t rcutils_string_array_resize(rcutils_string_array_t *string_array, size_t new_size)

Resize a string array, reclaiming removed resources.

This function changes the size of an existing string array. If the new size is larger, new entries are added to the end of the array and are zero- initialized. If the new size is smaller, entries are removed from the end of the array and their resources reclaimed.

Note:

Resizing to 0 is not a substitute for calling rcutils_string_array_fini.

Note:

If this function fails, string_array remains unchanged and should still be reclaimed with rcutils_string_array_fini.

Parameters:
  • string_array[inout] object to be resized.

  • new_size[in] the size the array should be changed to.

Returns:

RCUTILS_RET_OK if successful, or

Returns:

RCUTILS_RET_INVALID_ARGUMENT for invalid arguments, or

Returns:

RCUTILS_RET_BAD_ALLOC if memory allocation fails, or

Returns:

RCUTILS_RET_ERROR if an unknown error occurs.