changes to support memory audit (#261)

* changes to rcutils_path_join()

* remove uses of malloc/realloc/calloc/free for allocator usage instead

* remove unused class members
This commit is contained in:
William Woodall 2018-06-16 22:06:07 -07:00 committed by GitHub
parent ced49473db
commit d63e2bc9cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 44 deletions

View file

@ -99,7 +99,7 @@ const char * rcl_create_node_logger_name(
return node_logger_name;
}
const char * rcl_get_secure_root(const char * node_name)
const char * rcl_get_secure_root(const char * node_name, const rcl_allocator_t * allocator)
{
const char * ros_secure_root_env = NULL;
if (NULL == node_name) {
@ -115,9 +115,9 @@ const char * rcl_get_secure_root(const char * node_name)
if (!ros_secure_root_size) {
return NULL; // environment variable was empty
}
char * node_secure_root = rcutils_join_path(ros_secure_root_env, node_name);
char * node_secure_root = rcutils_join_path(ros_secure_root_env, node_name, *allocator);
if (!rcutils_is_directory(node_secure_root)) {
free(node_secure_root);
allocator->deallocate(node_secure_root, allocator->state);
return NULL;
}
return node_secure_root;
@ -315,7 +315,7 @@ rcl_node_init(
node_security_options.enforce_security = RMW_SECURITY_ENFORCEMENT_PERMISSIVE;
} else { // if use_security
// File discovery magic here
const char * node_secure_root = rcl_get_secure_root(name);
const char * node_secure_root = rcl_get_secure_root(name, allocator);
if (node_secure_root) {
node_security_options.security_root_path = node_secure_root;
} else {

View file

@ -193,14 +193,14 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), default_clock_instanciation) {
EXPECT_EQ(retval, RCL_RET_OK) << rcl_get_error_string_safe();
ASSERT_TRUE(rcl_clock_valid(&ros_clock));
rcl_clock_t * steady_clock =
reinterpret_cast<rcl_clock_t *>(calloc(1, sizeof(rcl_clock_t)));
rcl_clock_t * steady_clock = reinterpret_cast<rcl_clock_t *>(
allocator.zero_allocate(1, sizeof(rcl_clock_t), allocator.state));
retval = rcl_steady_clock_init(steady_clock, &allocator);
EXPECT_EQ(retval, RCL_RET_OK) << rcl_get_error_string_safe();
ASSERT_TRUE(rcl_clock_valid(steady_clock));
rcl_clock_t * system_clock =
reinterpret_cast<rcl_clock_t *>(calloc(1, sizeof(rcl_clock_t)));
rcl_clock_t * system_clock = reinterpret_cast<rcl_clock_t *>(
allocator.zero_allocate(1, sizeof(rcl_clock_t), allocator.state));
retval = rcl_system_clock_init(system_clock, &allocator);
EXPECT_EQ(retval, RCL_RET_OK) << rcl_get_error_string_safe();
ASSERT_TRUE(rcl_clock_valid(system_clock));