@@ -311,12 +311,13 @@ DynamicMessageTypeSupport::init_rosidl_message_type_support_(
311311
312312 rosidl_dynamic_message_type_support_impl_t * ts_impl =
313313 new rosidl_dynamic_message_type_support_impl_t {
314- type_hash.get (), // type_hash
315- description, // type_description
316- nullptr , // NOTE(methylDragon): Not supported for now // type_description_sources
317- serialization_support->get_rosidl_serialization_support (), // serialization_support
318- dynamic_message_type->get_rosidl_dynamic_type (), // dynamic_message_type
319- dynamic_message->get_rosidl_dynamic_data () // dynamic_message
314+ rcutils_get_default_allocator (), // allocator
315+ type_hash.get (), // type_hash
316+ description, // type_description
317+ nullptr , // NOTE(methylDragon): Not supported for now // type_description_sources
318+ serialization_support->get_rosidl_serialization_support (), // serialization_support
319+ dynamic_message_type->get_rosidl_dynamic_type (), // dynamic_message_type
320+ dynamic_message->get_rosidl_dynamic_data () // dynamic_message
320321 };
321322 if (!ts_impl) {
322323 throw std::runtime_error (
@@ -326,26 +327,29 @@ DynamicMessageTypeSupport::init_rosidl_message_type_support_(
326327
327328 // NOTE(methylDragon): We don't finalize the rosidl_message_type_support->data since its members
328329 // are managed by the passed in SharedPtr wrapper classes. We just delete it.
330+ /* *INDENT-OFF* */
329331 rosidl_message_type_support_.reset (
330332 new rosidl_message_type_support_t {
331- rmw_get_dynamic_typesupport_identifier (), // typesupport_identifier
332- ts_impl, // data
333- get_message_typesupport_handle_function, // func
334- // get_type_hash_func
335- rosidl_get_dynamic_message_type_support_type_hash_function,
336- // get_type_description_func
337- rosidl_get_dynamic_message_type_support_type_description_function,
333+ rmw_get_dynamic_typesupport_identifier (), // typesupport_identifier
334+ ts_impl, // data
335+ get_message_typesupport_handle_function, // func
336+ rosidl_get_dynamic_message_type_support_type_hash_function, // get_type_hash_func
337+ rosidl_get_dynamic_message_type_support_type_description_function, // get_type_description_func
338338 // get_type_description_sources_func
339339 rosidl_get_dynamic_message_type_support_type_description_sources_function
340- },
340+ },
341+ // Custom deleter
341342 [](rosidl_message_type_support_t * ts) -> void {
342343 auto ts_impl = static_cast <const rosidl_dynamic_message_type_support_impl_t *>(ts->data );
344+ // User might have passed in a different allocator, but the type hash was allocated using
345+ // the default
343346 auto allocator = rcl_get_default_allocator ();
344347 // Only because we should've allocated it here (also it's C allocated)
345348 allocator.deallocate (ts_impl->type_hash , &allocator.state );
346349 delete ts_impl;
347350 }
348351 );
352+ /* *INDENT-ON* */
349353
350354 if (!rosidl_message_type_support_) {
351355 throw std::runtime_error (" Could not allocate rosidl_message_type_support_t struct" );
0 commit comments