2121#include <rmw/allocators.h>
2222#include <uxr/client/util/time.h>
2323
24+ #include "rcutils/strdup.h"
25+
2426#include "./rmw_microros_internal/callbacks.h"
2527#include "./rmw_microros_internal/types.h"
2628#include "./rmw_microros_internal/utils.h"
@@ -52,7 +54,7 @@ rmw_init_options_init(
5254 init_options -> instance_id = 0 ;
5355 init_options -> implementation_identifier = eprosima_microxrcedds_identifier ;
5456 init_options -> allocator = allocator ;
55- init_options -> enclave = "/" ;
57+ init_options -> enclave = NULL ;
5658 init_options -> domain_id = 0 ;
5759 init_options -> security_options = rmw_get_default_security_options ();
5860 init_options -> localhost_only = RMW_LOCALHOST_ONLY_DEFAULT ;
@@ -135,8 +137,16 @@ rmw_init_options_copy(
135137 }
136138 memcpy (dst , src , sizeof (rmw_init_options_t ));
137139
140+ rcutils_allocator_t allocator = src -> allocator ;
141+ RCUTILS_CHECK_ALLOCATOR (& allocator , return RMW_RET_INVALID_ARGUMENT );
142+ dst -> enclave = rcutils_strdup (src -> enclave , allocator );
143+ if (NULL != src -> enclave && NULL == dst -> enclave ) {
144+ return RMW_RET_BAD_ALLOC ;
145+ }
146+
138147 rmw_uxrce_mempool_item_t * memory_node = get_memory (& init_options_memory );
139148 if (!memory_node ) {
149+ allocator .deallocate (dst -> enclave , allocator .state );
140150 RMW_UROS_TRACE_MESSAGE ("Not available memory node" )
141151 return RMW_RET_ERROR ;
142152 }
@@ -155,7 +165,8 @@ rmw_init_options_fini(
155165 rmw_init_options_t * init_options )
156166{
157167 RMW_CHECK_ARGUMENT_FOR_NULL (init_options , RMW_RET_INVALID_ARGUMENT );
158- RCUTILS_CHECK_ALLOCATOR (& (init_options -> allocator ), return RMW_RET_INVALID_ARGUMENT );
168+ rcutils_allocator_t * allocator = & init_options -> allocator ;
169+ RCUTILS_CHECK_ALLOCATOR (allocator , return RMW_RET_INVALID_ARGUMENT );
159170 RMW_CHECK_TYPE_IDENTIFIERS_MATCH (
160171 init_options -> implementation_identifier ,
161172 RMW_RET_INCORRECT_RMW_IMPLEMENTATION );
@@ -176,6 +187,7 @@ rmw_init_options_fini(
176187 return RMW_RET_ERROR ;
177188 }
178189
190+ allocator -> deallocate (init_options -> enclave , allocator -> state );
179191
180192 * init_options = rmw_get_zero_initialized_init_options ();
181193
0 commit comments