@@ -53,7 +53,8 @@ rcl_publisher_init(
5353 const rcl_node_t * node ,
5454 const rosidl_message_type_support_t * type_support ,
5555 const char * topic_name ,
56- const rcl_publisher_options_t * options )
56+ const rcl_publisher_options_t * options
57+ )
5758{
5859 rcl_ret_t fail_ret = RCL_RET_ERROR ;
5960
@@ -74,6 +75,8 @@ rcl_publisher_init(
7475 RCL_CHECK_ARGUMENT_FOR_NULL (topic_name , RCL_RET_INVALID_ARGUMENT );
7576 RCUTILS_LOG_DEBUG_NAMED (
7677 ROS_PACKAGE_NAME , "Initializing publisher for topic name '%s'" , topic_name );
78+
79+
7780 // Expand the given topic name.
7881 rcutils_allocator_t rcutils_allocator = * allocator ; // implicit conversion to rcutils version
7982 rcutils_string_map_t substitutions_map = rcutils_get_zero_initialized_string_map ();
@@ -162,6 +165,7 @@ rcl_publisher_init(
162165 sizeof (rcl_publisher_impl_t ), allocator -> state );
163166 RCL_CHECK_FOR_NULL_WITH_MSG (
164167 publisher -> impl , "allocating memory failed" , ret = RCL_RET_BAD_ALLOC ; goto cleanup );
168+
165169 // Fill out implementation struct.
166170 // rmw handle (create rmw publisher)
167171 // TODO(wjwwood): pass along the allocator to rmw when it supports it
@@ -188,11 +192,13 @@ rcl_publisher_init(
188192 RCUTILS_LOG_DEBUG_NAMED (ROS_PACKAGE_NAME , "Publisher initialized" );
189193 // context
190194 publisher -> impl -> context = node -> context ;
195+
191196 goto cleanup ;
192197fail :
193198 if (publisher -> impl ) {
194199 allocator -> deallocate (publisher -> impl , allocator -> state );
195200 }
201+
196202 ret = fail_ret ;
197203 // Fall through to cleanup
198204cleanup :
@@ -245,13 +251,16 @@ rcl_publisher_get_default_options()
245251}
246252
247253rcl_ret_t
248- rcl_publish (const rcl_publisher_t * publisher , const void * ros_message )
254+ rcl_publish (
255+ const rcl_publisher_t * publisher ,
256+ const void * ros_message ,
257+ rmw_publisher_allocation_t * allocation )
249258{
250259 if (!rcl_publisher_is_valid (publisher )) {
251260 return RCL_RET_PUBLISHER_INVALID ; // error already set
252261 }
253262 RCL_CHECK_ARGUMENT_FOR_NULL (ros_message , RCL_RET_INVALID_ARGUMENT );
254- if (rmw_publish (publisher -> impl -> rmw_handle , ros_message ) != RMW_RET_OK ) {
263+ if (rmw_publish (publisher -> impl -> rmw_handle , ros_message , allocation ) != RMW_RET_OK ) {
255264 RCL_SET_ERROR_MSG (rmw_get_error_string ().str );
256265 return RCL_RET_ERROR ;
257266 }
@@ -260,13 +269,16 @@ rcl_publish(const rcl_publisher_t * publisher, const void * ros_message)
260269
261270rcl_ret_t
262271rcl_publish_serialized_message (
263- const rcl_publisher_t * publisher , const rcl_serialized_message_t * serialized_message )
272+ const rcl_publisher_t * publisher ,
273+ const rcl_serialized_message_t * serialized_message ,
274+ rmw_publisher_allocation_t * allocation )
264275{
265276 if (!rcl_publisher_is_valid (publisher )) {
266277 return RCL_RET_PUBLISHER_INVALID ; // error already set
267278 }
268279 RCL_CHECK_ARGUMENT_FOR_NULL (serialized_message , RCL_RET_INVALID_ARGUMENT );
269- rmw_ret_t ret = rmw_publish_serialized_message (publisher -> impl -> rmw_handle , serialized_message );
280+ rmw_ret_t ret = rmw_publish_serialized_message (publisher -> impl -> rmw_handle , serialized_message ,
281+ allocation );
270282 if (ret != RMW_RET_OK ) {
271283 RCL_SET_ERROR_MSG (rmw_get_error_string ().str );
272284 if (ret == RMW_RET_BAD_ALLOC ) {
0 commit comments