Skip to content

Commit 0e114fe

Browse files
committed
Add note about *Unsafe consuming the input buffer
1 parent 5edab9e commit 0e114fe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mem/buffers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,19 @@ func (b *buffer) String() string {
207207

208208
// ReadUnsafe reads bytes from the given Buffer into the provided slice.
209209
// It does not perform safety checks.
210+
//
211+
// The returned Buffer MUST be used in place of the one passed in, as it may
212+
// have been modified or freed.
210213
func ReadUnsafe(dst []byte, buf Buffer) (int, Buffer) {
211214
return buf.read(dst)
212215
}
213216

214217
// SplitUnsafe modifies the receiver to point to the first n bytes while it
215218
// returns a new reference to the remaining bytes. The returned Buffer
216219
// functions just like a normal reference acquired using Ref().
220+
//
221+
// The returned Buffer values MUST be used in place of the one passed in, as it
222+
// may have been modified or freed.
217223
func SplitUnsafe(buf Buffer, n int) (left, right Buffer) {
218224
return buf.split(n)
219225
}

0 commit comments

Comments
 (0)