Skip to content

Commit 15e951c

Browse files
committed
Make _z_iosli_copy_bytes() copy rather data than append.
1 parent 475aed7 commit 15e951c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

include/zenoh-pico/protocol/iobuf.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ static inline void _z_iosli_read_bytes(_z_iosli_t *ios, uint8_t *dst, size_t off
8282
static inline void _z_iosli_copy_bytes(_z_iosli_t *dst, const _z_iosli_t *src) {
8383
size_t length = _z_iosli_readable(src);
8484
assert(dst->_capacity >= length);
85-
(void)memcpy(dst->_buf + dst->_w_pos, src->_buf + src->_r_pos, length);
86-
dst->_w_pos += length;
85+
(void)memcpy(dst->_buf, src->_buf + src->_r_pos, length);
86+
dst->_r_pos = 0;
87+
dst->_w_pos = length;
8788
}
8889
static inline void _z_iosli_write_bytes(_z_iosli_t *ios, const uint8_t *bs, size_t offset, size_t length) {
8990
assert(_z_iosli_writable(ios) >= length);

0 commit comments

Comments
 (0)