Skip to content

Commit

Permalink
Merge pull request #9 from sunfuze/fix-makespace
Browse files Browse the repository at this point in the history
after makespace should recompute vr value
  • Loading branch information
Allenxuxu authored Nov 8, 2021
2 parents 7371440 + df7867a commit 02ee0d3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ring_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,15 @@ func (r *RingBuffer) String() string {
}

func (r *RingBuffer) makeSpace(len int) {
vlen := r.VirtualLength()
newSize := r.size + len
newBuf := make([]byte, newSize, newSize)
oldLen := r.Length()
_, _ = r.Read(newBuf)

r.w = oldLen
r.r = 0
r.vr = oldLen - vlen
r.size = newSize
r.buf = newBuf
}
Expand Down

0 comments on commit 02ee0d3

Please sign in to comment.