Adds exactly bytes of unwritten length to the buffer, possibly across packet buffer boundaries, and initializes buf to point to the packet buffer(s) that contain the unwritten space
| 75 | // Adds exactly bytes of unwritten length to the buffer, possibly across packet buffer boundaries, |
| 76 | // and initializes buf to point to the packet buffer(s) that contain the unwritten space |
| 77 | void PacketWriter::writeAhead(int bytes, struct SplitBuffer* buf) { |
| 78 | if (bytes <= buffer->bytes_unwritten()) { |
| 79 | buf->begin = buffer->data() + buffer->bytes_written; |
| 80 | buf->first_length = bytes; |
| 81 | buffer->bytes_written += bytes; |
| 82 | buf->next = 0; |
| 83 | } else { |
| 84 | buf->begin = buffer->data() + buffer->bytes_written; |
| 85 | buf->first_length = buffer->bytes_unwritten(); |
| 86 | buffer->bytes_written = buffer->size(); |
| 87 | size_t remaining = bytes - buf->first_length; |
| 88 | nextBuffer(remaining); |
| 89 | buf->next = buffer->data(); |
| 90 | buffer->bytes_written = remaining; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | void SplitBuffer::write(const void* data, int len) { |
| 95 | write(data, len, 0); |
no test coverage detected