21
21
#include <rmw/allocators.h>
22
22
#include <uxr/client/util/time.h>
23
23
24
+ #include "rcutils/strdup.h"
25
+
24
26
#include "./rmw_microros_internal/callbacks.h"
25
27
#include "./rmw_microros_internal/types.h"
26
28
#include "./rmw_microros_internal/utils.h"
@@ -52,7 +54,7 @@ rmw_init_options_init(
52
54
init_options -> instance_id = 0 ;
53
55
init_options -> implementation_identifier = eprosima_microxrcedds_identifier ;
54
56
init_options -> allocator = allocator ;
55
- init_options -> enclave = "/" ;
57
+ init_options -> enclave = NULL ;
56
58
init_options -> domain_id = 0 ;
57
59
init_options -> security_options = rmw_get_default_security_options ();
58
60
init_options -> localhost_only = RMW_LOCALHOST_ONLY_DEFAULT ;
@@ -135,8 +137,16 @@ rmw_init_options_copy(
135
137
}
136
138
memcpy (dst , src , sizeof (rmw_init_options_t ));
137
139
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
+
138
147
rmw_uxrce_mempool_item_t * memory_node = get_memory (& init_options_memory );
139
148
if (!memory_node ) {
149
+ allocator .deallocate (dst -> enclave , allocator .state );
140
150
RMW_UROS_TRACE_MESSAGE ("Not available memory node" )
141
151
return RMW_RET_ERROR ;
142
152
}
@@ -155,7 +165,8 @@ rmw_init_options_fini(
155
165
rmw_init_options_t * init_options )
156
166
{
157
167
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 );
159
170
RMW_CHECK_TYPE_IDENTIFIERS_MATCH (
160
171
init_options -> implementation_identifier ,
161
172
RMW_RET_INCORRECT_RMW_IMPLEMENTATION );
@@ -176,6 +187,7 @@ rmw_init_options_fini(
176
187
return RMW_RET_ERROR ;
177
188
}
178
189
190
+ allocator -> deallocate (init_options -> enclave , allocator -> state );
179
191
180
192
* init_options = rmw_get_zero_initialized_init_options ();
181
193
0 commit comments