mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Improve event passing clarity
This commit is contained in:
@@ -37,14 +37,14 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
|||||||
response.data);
|
response.data);
|
||||||
}
|
}
|
||||||
if (response.data.has_value()) {
|
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
|
// For correctness we will copy the entire buffer and add a terminating
|
||||||
// null byte ourselves. In practice `response.data` will only ever
|
// null byte ourselves. In practice `response.data` will only ever
|
||||||
// contain C-style strings, but this would work with any other data
|
// contain C-style strings, but this would work with any other data
|
||||||
// format that can contain null bytes.
|
// format that can contain null bytes.
|
||||||
std::copy(response.data->begin(), response.data->end(), char_data);
|
std::copy(response.data->begin(), response.data->end(), output);
|
||||||
char_data[response.data->size()] = 0;
|
output[response.data->size()] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.return_value;
|
return response.return_value;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
|
|||||||
const auto response_data =
|
const auto response_data =
|
||||||
std::holds_alternative<std::array<char, max_string_length>>(
|
std::holds_alternative<std::array<char, max_string_length>>(
|
||||||
event.payload)
|
event.payload)
|
||||||
? std::make_optional(static_cast<char*>(data))
|
? std::optional(std::string(static_cast<char*>(data)))
|
||||||
: std::nullopt;
|
: std::nullopt;
|
||||||
|
|
||||||
if (logging.has_value()) {
|
if (logging.has_value()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user