Skip to content

Commit

Permalink
Fix message_id_generator lifetime issue
Browse files Browse the repository at this point in the history
Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass committed Jan 17, 2024
1 parent 9afe405 commit f752501
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/ocpp/v201/notify_report_requests_splitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class NotifyReportRequestsSplitter {
const NotifyReportRequest& original_request;
// cppcheck-suppress unusedStructMember
size_t max_size;
const std::function<MessageId()>& message_id_generator_callback;
const std::function<MessageId()> message_id_generator_callback;
json request_json_template; // json that is used as template for request json
// cppcheck-suppress unusedStructMember
const size_t json_skeleton_size; // size of the json skeleton for a call json object which includes everything
// except the requests' reportData and the messageId

public:
NotifyReportRequestsSplitter(const NotifyReportRequest& originalRequest, size_t max_size,
const std::function<MessageId()>& message_id_generator_callback);
std::function<MessageId()>&& message_id_generator_callback);
NotifyReportRequestsSplitter() = delete;

/// \brief Splits the provided NotifyReportRequest into (potentially) several Call payloads
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/v201/notify_report_requests_splitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ json NotifyReportRequestsSplitter::create_next_payload(
}
NotifyReportRequestsSplitter::NotifyReportRequestsSplitter(
const NotifyReportRequest& originalRequest, size_t max_size,
const std::function<MessageId()>& message_id_generator_callback) :
std::function<MessageId()>&& message_id_generator_callback) :
original_request(originalRequest),
max_size(max_size),
message_id_generator_callback(message_id_generator_callback),
message_id_generator_callback{std::move(message_id_generator_callback)},
json_skeleton_size(create_request_template_json_and_return_skeleton_size()) {
}

Expand Down

0 comments on commit f752501

Please sign in to comment.