Documentation ¶
Overview ¶
Package bufferpool maintains a pool of bytes.Buffers for use in encoding and transport implementations.
Index ¶
- func Put(buf *Buffer)
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Len() int
- func (b *Buffer) Read(p []byte) (int, error)
- func (b *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (b *Buffer) Release()
- func (b *Buffer) Reset()
- func (b *Buffer) Write(p []byte) (int, error)
- func (b *Buffer) WriteTo(w io.Writer) (int64, error)
- type Option
- type Pool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶ added in v1.27.0
type Buffer struct {
// contains filtered or unexported fields
}
Buffer represents a poolable buffer. It wraps an underlying *bytes.Buffer with lightweight detection of races.
func (*Buffer) Bytes ¶ added in v1.27.0
Bytes returns the bytes in the underlying buffer, as well as a function to call when the caller is done using the bytes. This is easy to mis-use and lead to a use-after-free that cannot be detected, so it is strongly recommended that this method is NOT used.
func (*Buffer) Release ¶ added in v1.27.0
func (b *Buffer) Release()
Release releases the buffer back to the buffer pool.
func (*Buffer) Reset ¶ added in v1.27.0
func (b *Buffer) Reset()
Reset is the same as bytes.Buffer.Reset.
type Option ¶ added in v1.27.0
type Option func(*Pool)
Option configures a buffer pool.
func DetectUseAfterFreeForTests ¶ added in v1.27.0
func DetectUseAfterFreeForTests() Option
DetectUseAfterFreeForTests is an option that allows unit tests to detect bad use of a pooled buffer after it has been released to the pool.