mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 18:15:51 +00:00
28 lines
472 B
Go
28 lines
472 B
Go
package bytespool
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/cubefs/cubefs/blobstore/util/bytespool"
|
|
)
|
|
|
|
var (
|
|
GetPool = bytespool.GetPool
|
|
Alloc = bytespool.Alloc
|
|
Free = bytespool.Free
|
|
Zero = bytespool.Zero
|
|
)
|
|
|
|
// NewBuffer returns empty buffer with sized capacity.
|
|
func NewBuffer(size int) *bytes.Buffer {
|
|
b := bytes.NewBuffer(Alloc(size))
|
|
b.Reset()
|
|
return b
|
|
}
|
|
|
|
// FreeBuffer free the underlying bytes.
|
|
func FreeBuffer(b *bytes.Buffer) {
|
|
b.Reset()
|
|
Free(b.Bytes())
|
|
}
|