Skip to content

Commit

Permalink
Copy parameter file names
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz authored and mikaelarguedas committed Jun 5, 2018
1 parent 449ccb9 commit dd0f088
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions rcl/src/rcl/arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ rcl_arguments_copy(
// Zero so it's safe to call rcl_arguments_fini() if an error occurrs while copying.
args_out->impl->num_remap_rules = 0;
args_out->impl->num_unparsed_args = 0;
args_out->impl->num_param_files_args = 0;

// Copy unparsed args
args_out->impl->unparsed_args = allocator.allocate(
Expand Down Expand Up @@ -382,6 +383,30 @@ rcl_arguments_copy(
return ret;
}
}
// Copy parameter files
if (args->impl->num_param_files_args) {
args_out->impl->parameter_files = allocator.allocate(
sizeof(char *) * args->impl->num_param_files_args, allocator.state);
if (NULL == args_out->impl->parameter_files) {
if (RCL_RET_OK != rcl_arguments_fini(args_out)) {
RCL_SET_ERROR_MSG("Error while finalizing arguments due to another error", error_alloc);
}
return RCL_RET_BAD_ALLOC;
}
args_out->impl->num_param_files_args = args->impl->num_param_files_args;
for (int i = 0; i < args->impl->num_param_files_args; ++i) {
args_out->impl->parameter_files[i] =
rcutils_strdup(args->impl->parameter_files[i], allocator);
if (NULL == args_out->impl->parameter_files[i]) {
if (RCL_RET_OK != rcl_arguments_fini(args_out)) {
RCL_SET_ERROR_MSG("Error while finalizing arguments due to another error", error_alloc);
}
return RCL_RET_BAD_ALLOC;
}
}
} else {
args_out->impl->parameter_files = NULL;
}
return RCL_RET_OK;
}

Expand Down

0 comments on commit dd0f088

Please sign in to comment.