Fix bugs in BytesMut::reserve_inner (#544)

This commit is contained in:
Jiahao XU
2022-04-28 11:37:33 +02:00
committed by GitHub
parent 8198f9e28e
commit 0a2c43af88
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -646,7 +646,7 @@ impl BytesMut {
self.cap = v.capacity();
} else {
// calculate offset
let off = v.capacity() - self.cap;
let off = (self.ptr.as_ptr() as usize) - (v.as_ptr() as usize);
// new_cap is calculated in terms of `BytesMut`, not the underlying
// `Vec`, so it does not take the offset into account.