diff --git a/include/rcutils/split.h b/include/rcutils/split.h index ec62f772..b682901d 100644 --- a/include/rcutils/split.h +++ b/include/rcutils/split.h @@ -52,6 +52,7 @@ rcutils_split( * \param[in] allocator for allocating new memory for the output array * \param[out] string_array with the split tokens * \return #RCUTILS_RET_OK if successful, or + * \return #RCUTILS_RET_BAD_ALLOC if memory allocation fails, or * \return #RCUTILS_RET_ERROR if an unknown error occurs */ RCUTILS_PUBLIC diff --git a/src/split.c b/src/split.c index a807be2b..275da14d 100644 --- a/src/split.c +++ b/src/split.c @@ -118,7 +118,7 @@ rcutils_split( } RCUTILS_SET_ERROR_MSG("unable to allocate memory for string array data"); - return RCUTILS_RET_ERROR; + return RCUTILS_RET_BAD_ALLOC; } rcutils_ret_t diff --git a/test/test_split.cpp b/test/test_split.cpp index 8a5724a0..02aa8f77 100644 --- a/test/test_split.cpp +++ b/test/test_split.cpp @@ -68,13 +68,13 @@ TEST(test_split, split) { rcutils_allocator_t time_bomb_allocator = get_time_bomb_allocator(); set_time_bomb_allocator_malloc_count(time_bomb_allocator, 0); EXPECT_EQ( - RCUTILS_RET_ERROR, + RCUTILS_RET_BAD_ALLOC, rcutils_split("Test", '/', time_bomb_allocator, &tokens_fail)); // Allocating string_array->data[0] fails set_time_bomb_allocator_malloc_count(time_bomb_allocator, 1); EXPECT_EQ( - RCUTILS_RET_ERROR, + RCUTILS_RET_BAD_ALLOC, rcutils_split("hello/world", '/', time_bomb_allocator, &tokens_fail)); rcutils_string_array_t tokens0 = test_split("", '/', 0);