Skip to content

Commit

Permalink
fixed memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
gilpazintel committed Feb 18, 2025
1 parent 8ed6e12 commit 7fb3959
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/linux/backend-hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ namespace librealsense
return false;
}

bool iio_hid_sensor::sort_hids(hid_input* first, hid_input* second)
bool iio_hid_sensor::sort_hids(std::shared_ptr<hid_input> first, std::shared_ptr<hid_input> second)
{
return (second->get_hid_input_info().index >= first->get_hid_input_info().index);
}
Expand Down Expand Up @@ -980,8 +980,9 @@ namespace librealsense

try
{
auto* new_input = new hid_input(_iio_device_path, file);
auto new_input = std::make_shared<hid_input>(_iio_device_path, file);
// push to input list.

_inputs.push_front(new_input);
}
catch(...)
Expand Down
6 changes: 3 additions & 3 deletions src/linux/backend-hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace librealsense

bool has_metadata();

static bool sort_hids(hid_input* first, hid_input* second);
static bool sort_hids(std::shared_ptr<hid_input> first, std::shared_ptr<hid_input> second);

void create_channel_array();

Expand All @@ -181,8 +181,8 @@ namespace librealsense
std::string _sensor_name;
std::string _sampling_frequency_name;
std::string _sensitivity_name;
std::list<hid_input*> _inputs;
std::list<hid_input*> _channels;
std::list<std::shared_ptr<hid_input>> _inputs;
std::list<std::shared_ptr<hid_input>> _channels;
hid_callback _callback;
std::atomic<bool> _is_capturing;
std::unique_ptr<std::thread> _hid_thread;
Expand Down

0 comments on commit 7fb3959

Please sign in to comment.