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

fix leak in test_init #440

Merged
merged 1 commit into from
May 16, 2019
Merged
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
9 changes: 6 additions & 3 deletions rcl/test/rcl/test_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CLASSNAME (TestRCLFixture, RMW_IMPLEMENTATION) : public ::testing::Test
struct FakeTestArgv
{
FakeTestArgv()
: allocator(rcutils_get_default_allocator()), argc(2)
: allocator(rcl_get_default_allocator()), argc(2)
{
this->argv =
static_cast<char **>(allocator.allocate(2 * sizeof(char *), allocator.state));
Expand All @@ -82,15 +82,15 @@ struct FakeTestArgv
if (this->argv) {
if (this->argc > 0) {
size_t unsigned_argc = this->argc;
for (size_t i = 0; i < unsigned_argc; --i) {
for (size_t i = 0; i < unsigned_argc; ++i) {
allocator.deallocate(this->argv[i], allocator.state);
}
}
}
allocator.deallocate(this->argv, allocator.state);
}

rcutils_allocator_t allocator;
rcl_allocator_t allocator;
int argc;
char ** argv;

Expand Down Expand Up @@ -201,6 +201,9 @@ TEST_F(CLASSNAME(TestRCLFixture, RMW_IMPLEMENTATION), test_rcl_init_and_ok_and_s
ret = rcl_context_fini(&context);
EXPECT_EQ(ret, RCL_RET_OK);
context = rcl_get_zero_initialized_context();
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
EXPECT_EQ(RCL_RET_OK, rcl_init_options_fini(&init_options)) << rcl_get_error_string().str;
});
}

/* Tests the rcl_get_instance_id() and rcl_ok() functions.
Expand Down