missinggo.LimitLen changed
This commit is contained in:
parent
fa7c2e2bc6
commit
b9a1cb5b8b
|
@ -193,11 +193,10 @@ func (r *Reader) readOnceAt(b []byte, pos int64, ctxErr *error) (n int, err erro
|
|||
return
|
||||
}
|
||||
}
|
||||
b1 := b[:avail]
|
||||
pi := int(pos / r.t.info.PieceLength)
|
||||
ip := r.t.info.Piece(pi)
|
||||
po := pos % r.t.info.PieceLength
|
||||
missinggo.LimitLen(&b1, ip.Length()-po)
|
||||
b1 := missinggo.LimitLen(b, ip.Length()-po, avail)
|
||||
n, err = r.t.readAt(b1, pos)
|
||||
if n != 0 {
|
||||
err = nil
|
||||
|
|
|
@ -45,7 +45,7 @@ func (p Piece) WriteAt(b []byte, off int64) (n int, err error) {
|
|||
if off+int64(len(b)) > p.mip.Length() {
|
||||
panic("write overflows piece")
|
||||
}
|
||||
missinggo.LimitLen(&b, p.mip.Length()-off)
|
||||
b = missinggo.LimitLen(b, p.mip.Length()-off)
|
||||
return p.PieceImpl.WriteAt(b, off)
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ func (p Piece) ReadAt(b []byte, off int64) (n int, err error) {
|
|||
err = io.EOF
|
||||
return
|
||||
}
|
||||
missinggo.LimitLen(&b, p.mip.Length()-off)
|
||||
b = missinggo.LimitLen(b, p.mip.Length()-off)
|
||||
if len(b) == 0 {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue