]> Sergey Matveev's repositories - btrtrc.git/commitdiff
missinggo.LimitLen changed
authorMatt Joiner <anacrolix@gmail.com>
Sun, 3 Dec 2017 02:44:08 +0000 (13:44 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 3 Dec 2017 02:44:08 +0000 (13:44 +1100)
reader.go
storage/wrappers.go

index 5c3bccada2fb743dbfac9eab4ec2d6d3a1af9613..bdfeed04047fa2001668dea64e87353d2ee7abcc 100644 (file)
--- a/reader.go
+++ b/reader.go
@@ -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
index b8ba050b5503cd1729bff7f35e9d9285ffbe6283..044a1f5aa53fd62de03e4cdeed76e14d1f4189f6 100644 (file)
@@ -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
        }