diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-02 19:48:24 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-02 19:48:24 +0200 |
commit | 9ecd09263535843e287048d299ca5bdfc85d18d9 (patch) | |
tree | f6c424072a154775ff890cbbf90f8b48d9319d42 /CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp | |
parent | 4ab2164774bdb9a29b2f180a9013c26c0155628d (diff) |
Remove pointer generator that make memory leaks.
Only have 1 place where to generate a pointer from a DiagnosticRequest
is in low-can-cb.cpp when subscribing. Else now using reference instead
of raw pointer.
Change-Id: I7fd2f3d30afa90017b945e6b711922036123b6d3
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp')
-rw-r--r-- | CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp index fd4fbd29..ac91ae5b 100644 --- a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp +++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp @@ -246,13 +246,13 @@ void diagnostic_manager_t::cleanup_active_requests(bool force) /// /// @param[in] request - Search key, method will go through recurring list to see if it find that request /// holded by the DiagnosticHandle member. -active_diagnostic_request_t* diagnostic_manager_t::find_recurring_request(const DiagnosticRequest* request) +active_diagnostic_request_t* diagnostic_manager_t::find_recurring_request(DiagnosticRequest& request) { for (auto& entry : recurring_requests_) { if(entry != nullptr) { - if(diagnostic_request_equals(&entry->get_handle()->request, request)) + if(diagnostic_request_equals(&entry->get_handle()->request, &request)) {return entry;} } } @@ -297,7 +297,7 @@ active_diagnostic_request_t* diagnostic_manager_t::add_request(DiagnosticRequest { // TODO: implement Acceptance Filter // if(updateRequiredAcceptanceFilters(bus, request)) { - active_diagnostic_request_t* entry = new active_diagnostic_request_t(bus_, request, name, + active_diagnostic_request_t* entry = new active_diagnostic_request_t(bus_, request->arbitration_id, name, wait_for_multiple_responses, decoder, callback, 0); entry->set_handle(shims_, request); @@ -393,11 +393,11 @@ active_diagnostic_request_t* diagnostic_manager_t::add_recurring_request(Diagnos cleanup_active_requests(false); - if(find_recurring_request(request) == nullptr) + if(find_recurring_request(*request) == nullptr) { if(recurring_requests_.size() <= MAX_SIMULTANEOUS_DIAG_REQUESTS) { - entry = new active_diagnostic_request_t(bus_, request, name, + entry = new active_diagnostic_request_t(bus_, request->arbitration_id, name, wait_for_multiple_responses, decoder, callback, frequencyHz); recurring_requests_.push_back(entry); |