Skip to content

Commit 7406bdc

Browse files
authored
Fix memory leak in the ros2_control (#2033)
1 parent dab91b1 commit 7406bdc

File tree

13 files changed

+21
-45
lines changed

13 files changed

+21
-45
lines changed

hardware_interface/include/hardware_interface/actuator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class Actuator final
7272
const std::vector<std::string> & start_interfaces,
7373
const std::vector<std::string> & stop_interfaces);
7474

75-
std::string get_name() const;
75+
const std::string & get_name() const;
7676

77-
std::string get_group_name() const;
77+
const std::string & get_group_name() const;
7878

7979
const rclcpp_lifecycle::State & get_lifecycle_state() const;
8080

hardware_interface/include/hardware_interface/actuator_interface.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,13 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
461461
/**
462462
* \return name.
463463
*/
464-
virtual std::string get_name() const { return info_.name; }
464+
const std::string & get_name() const { return info_.name; }
465465

466466
/// Get name of the actuator hardware group to which it belongs to.
467467
/**
468468
* \return group name.
469469
*/
470-
virtual std::string get_group_name() const { return info_.group; }
470+
const std::string & get_group_name() const { return info_.group; }
471471

472472
/// Get life-cycle state of the actuator hardware.
473473
/**

hardware_interface/include/hardware_interface/hardware_info.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ struct InterfaceDescription
158158
*/
159159
std::string interface_name;
160160

161-
std::string get_prefix_name() const { return prefix_name; }
161+
const std::string & get_prefix_name() const { return prefix_name; }
162162

163-
std::string get_interface_name() const { return interface_info.name; }
163+
const std::string & get_interface_name() const { return interface_info.name; }
164164

165-
std::string get_name() const { return interface_name; }
165+
const std::string & get_name() const { return interface_name; }
166166
};
167167

168168
/// This structure stores information about hardware defined in a robot's URDF.

hardware_interface/include/hardware_interface/sensor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ class Sensor final
6262

6363
std::vector<StateInterface::ConstSharedPtr> export_state_interfaces();
6464

65-
std::string get_name() const;
65+
const std::string & get_name() const;
6666

67-
std::string get_group_name() const;
67+
const std::string & get_group_name() const;
6868

6969
const rclcpp_lifecycle::State & get_lifecycle_state() const;
7070

hardware_interface/include/hardware_interface/sensor_interface.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ class SensorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
275275
/**
276276
* \return name.
277277
*/
278-
virtual std::string get_name() const { return info_.name; }
278+
const std::string & get_name() const { return info_.name; }
279279

280280
/// Get name of the actuator hardware group to which it belongs to.
281281
/**
282282
* \return group name.
283283
*/
284-
virtual std::string get_group_name() const { return info_.group; }
284+
const std::string & get_group_name() const { return info_.group; }
285285

286286
/// Get life-cycle state of the actuator hardware.
287287
/**

hardware_interface/include/hardware_interface/system.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class System final
7272
const std::vector<std::string> & start_interfaces,
7373
const std::vector<std::string> & stop_interfaces);
7474

75-
std::string get_name() const;
75+
const std::string & get_name() const;
7676

77-
std::string get_group_name() const;
77+
const std::string & get_group_name() const;
7878

7979
const rclcpp_lifecycle::State & get_lifecycle_state() const;
8080

hardware_interface/include/hardware_interface/system_interface.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,13 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
490490
/**
491491
* \return name.
492492
*/
493-
virtual std::string get_name() const { return info_.name; }
493+
const std::string & get_name() const { return info_.name; }
494494

495495
/// Get name of the actuator hardware group to which it belongs to.
496496
/**
497497
* \return group name.
498498
*/
499-
virtual std::string get_group_name() const { return info_.group; }
499+
const std::string & get_group_name() const { return info_.group; }
500500

501501
/// Get life-cycle state of the actuator hardware.
502502
/**

hardware_interface/src/actuator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ return_type Actuator::perform_command_mode_switch(
277277
return impl_->perform_command_mode_switch(start_interfaces, stop_interfaces);
278278
}
279279

280-
std::string Actuator::get_name() const { return impl_->get_name(); }
280+
const std::string & Actuator::get_name() const { return impl_->get_name(); }
281281

282-
std::string Actuator::get_group_name() const { return impl_->get_group_name(); }
282+
const std::string & Actuator::get_group_name() const { return impl_->get_group_name(); }
283283

284284
const rclcpp_lifecycle::State & Actuator::get_lifecycle_state() const
285285
{

hardware_interface/src/sensor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ std::vector<StateInterface::ConstSharedPtr> Sensor::export_state_interfaces()
233233
// END: for backward compatibility
234234
}
235235

236-
std::string Sensor::get_name() const { return impl_->get_name(); }
236+
const std::string & Sensor::get_name() const { return impl_->get_name(); }
237237

238-
std::string Sensor::get_group_name() const { return impl_->get_group_name(); }
238+
const std::string & Sensor::get_group_name() const { return impl_->get_group_name(); }
239239

240240
const rclcpp_lifecycle::State & Sensor::get_lifecycle_state() const
241241
{

hardware_interface/src/system.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ return_type System::perform_command_mode_switch(
275275
return impl_->perform_command_mode_switch(start_interfaces, stop_interfaces);
276276
}
277277

278-
std::string System::get_name() const { return impl_->get_name(); }
278+
const std::string & System::get_name() const { return impl_->get_name(); }
279279

280-
std::string System::get_group_name() const { return impl_->get_group_name(); }
280+
const std::string & System::get_group_name() const { return impl_->get_group_name(); }
281281

282282
const rclcpp_lifecycle::State & System::get_lifecycle_state() const
283283
{

0 commit comments

Comments
 (0)