Skip to content

Commit cdb0690

Browse files
committed
tweak docs
1 parent f545dfc commit cdb0690

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

block-buffer/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ impl<BS: BlockSizes, K: BufferKind> BlockBuffer<BS, K> {
189189
let buf = &mut g.0.buffer;
190190
// SAFETY: length of `left` is equal to number of remaining bytes in `buffer`,
191191
// so we can copy data into it and process `buffer` as fully initialized block.
192-
// Note that we may temporarily break the invariant, but we reset the buffer
193-
// immediately after `compress` using `Drop` impl of `ResetGuard`, so this code
194-
// is safe even if `compress` panics.
192+
// Note that this code can temporarily break the eager buffer invariant,
193+
// but we reset the buffer immediately after `compress` using `Drop` impl of
194+
// `ResetGuard`, so this code is safe even if `compress` panics.
195195
let block = unsafe {
196196
let buf_ptr = buf.as_mut_ptr().cast::<u8>().add(pos);
197197
ptr::copy_nonoverlapping(left.as_ptr(), buf_ptr, left.len());

block-buffer/src/read.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ impl<BS: BlockSizes> ReadBuffer<BS> {
113113
let g = ResetGuard(self);
114114
let buf = &mut g.0.buffer;
115115

116+
// Note that generated block is likely to break the `ReadBuffer` invariant.
117+
// We restore it using `set_pos_unchecked` below and in case if one of the closures
118+
// panic the buffer gets reset by the guard.
116119
gen_block(buf);
117120
read_fn(&buf[..read_len]);
118121

0 commit comments

Comments
 (0)