diff options
author | Andreas Kling <kling@serenityos.org> | 2020-12-19 11:30:02 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-19 11:30:02 +0100 |
commit | 0e4ecca33621b5f7df1a74c48e3e6da920889627 (patch) | |
tree | 6a860d2f803ec57f0a557b8f71813de51069e207 /Libraries | |
parent | d893498e5738b9d37bd07bdedb4709ae46750fbd (diff) | |
download | serenity-0e4ecca33621b5f7df1a74c48e3e6da920889627.zip |
LibIPC: Remove use of ByteBuffer::wrap()
ByteBuffer::wrap() was useful before we had Span. Let's see if we can't
get rid of some more ByteBuffer wrapping.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibIPC/Connection.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Libraries/LibIPC/Connection.h b/Libraries/LibIPC/Connection.h index 2b354378d1..3ee01a95a5 100644 --- a/Libraries/LibIPC/Connection.h +++ b/Libraries/LibIPC/Connection.h @@ -214,7 +214,7 @@ protected: if (message_size == 0 || bytes.size() - index - sizeof(uint32_t) < message_size) break; index += sizeof(message_size); - auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index); + auto remaining_bytes = ReadonlyBytes { bytes.data() + index, bytes.size() - index }; if (auto message = LocalEndpoint::decode_message(remaining_bytes, m_socket->fd())) { m_unprocessed_messages.append(message.release_nonnull()); } else if (auto message = PeerEndpoint::decode_message(remaining_bytes, m_socket->fd())) { @@ -229,12 +229,13 @@ protected: // Sometimes we might receive a partial message. That's okay, just stash away // the unprocessed bytes and we'll prepend them to the next incoming message // in the next run of this function. - auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index); + auto remaining_bytes = ByteBuffer::copy(bytes.data() + index, bytes.size() - index); if (!m_unprocessed_bytes.is_empty()) { dbg() << *this << "::drain_messages_from_peer: Already have unprocessed bytes"; shutdown(); + return false; } - m_unprocessed_bytes = remaining_bytes.isolated_copy(); + m_unprocessed_bytes = remaining_bytes; } if (!m_unprocessed_messages.is_empty()) { |