Improve event passing clarity

This commit is contained in:
Robbert van der Helm
2020-03-08 18:33:01 +01:00
parent 1434f5855b
commit 2326a92c62
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -37,14 +37,14 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
response.data);
}
if (response.data.has_value()) {
char* char_data = static_cast<char*>(data);
char* output = static_cast<char*>(data);
// For correctness we will copy the entire buffer and add a terminating
// null byte ourselves. In practice `response.data` will only ever
// contain C-style strings, but this would work with any other data
// format that can contain null bytes.
std::copy(response.data->begin(), response.data->end(), char_data);
char_data[response.data->size()] = 0;
std::copy(response.data->begin(), response.data->end(), output);
output[response.data->size()] = 0;
}
return response.return_value;
+1 -1
View File
@@ -183,7 +183,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
const auto response_data =
std::holds_alternative<std::array<char, max_string_length>>(
event.payload)
? std::make_optional(static_cast<char*>(data))
? std::optional(std::string(static_cast<char*>(data)))
: std::nullopt;
if (logging.has_value()) {