Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bad_alloc return to topic_endpoint_info functions #269

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rmw/include/rmw/topic_endpoint_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ rmw_topic_endpoint_info_fini(
* \param[in] allocator the allocator that will be used to allocate memory
* \returns `RMW_RET_OK` on successfully setting the topic_type, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand All @@ -104,6 +105,7 @@ rmw_topic_endpoint_info_set_topic_type(
* \param[in] allocator the allocator that will be used to allocate memory
* \returns `RMW_RET_OK` on successfully setting the node_name, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand All @@ -126,6 +128,7 @@ rmw_topic_endpoint_info_set_node_name(
* \param[in] allocator the allocator that will be used to allocate memory
* \returns `RMW_RET_OK` on successfully setting the node_namespace, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand All @@ -148,6 +151,7 @@ rmw_topic_endpoint_info_set_node_namespace(
* \returns `RMW_RET_OK` on successfully setting the gid, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_INVALID_ARGUMENT` size is greater than RMW_GID_STORAGE_SIZE, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand Down
3 changes: 3 additions & 0 deletions rmw/src/topic_endpoint_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ _rmw_topic_endpoint_info_copy_str(
}

*topic_endpoint_info_str = rcutils_strdup(str, *allocator);
if (NULL == *topic_endpoint_info_str) {
return RMW_RET_BAD_ALLOC;
}

return RMW_RET_OK;
}
Expand Down