diff options
Diffstat (limited to 'pkg/tcpip/buffer/prependable.go')
-rw-r--r-- | pkg/tcpip/buffer/prependable.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/tcpip/buffer/prependable.go b/pkg/tcpip/buffer/prependable.go index 2f9a23d61..57d1922ab 100644 --- a/pkg/tcpip/buffer/prependable.go +++ b/pkg/tcpip/buffer/prependable.go @@ -42,7 +42,7 @@ func NewPrependableFromView(v View, extraCap int) Prependable { if extraCap == 0 { return Prependable{buf: v, usedIdx: 0} } - buf := make([]byte, extraCap, extraCap + len(v)) + buf := make([]byte, extraCap, extraCap+len(v)) buf = append(buf, v...) return Prependable{buf: buf, usedIdx: extraCap} } @@ -83,3 +83,9 @@ func (p *Prependable) Prepend(size int) []byte { p.usedIdx -= size return p.View()[:size:size] } + +// DeepCopy copies p and the bytes backing it. +func (p Prependable) DeepCopy() Prependable { + p.buf = append(View(nil), p.buf...) + return p +} |