Skip to content

Commit

Permalink
fix two bugs in new init code
Browse files Browse the repository at this point in the history
  • Loading branch information
wjwwood committed Nov 21, 2018
1 parent eeefecd commit 5f5c4a2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rcl/src/rcl/init.c
Expand Up @@ -28,7 +28,7 @@ extern "C"
#include "rcutils/stdatomic_helper.h"
#include "rmw/error_handling.h"

static atomic_uint_least64_t __rcl_next_unique_id = ATOMIC_VAR_INIT(0);
static atomic_uint_least64_t __rcl_next_unique_id = ATOMIC_VAR_INIT(1);

rcl_ret_t
rcl_init(
Expand Down Expand Up @@ -72,6 +72,8 @@ rcl_init(
context->impl = allocator.allocate(sizeof(rcl_context_impl_t), allocator.state);
RCL_CHECK_FOR_NULL_WITH_MSG(
context->impl, "failed to allocate memory for context impl", return RCL_RET_BAD_ALLOC);
// memset to 0 so the cleanup function will not try to clean up uninitialized parts later
memset(context->impl, 0x0, sizeof(rcl_context_impl_t));

// Copy the options into the context for future reference.
rcl_ret_t ret = rcl_init_options_copy(options, &(context->impl->init_options));
Expand Down

0 comments on commit 5f5c4a2

Please sign in to comment.