Files
6543andGitHub f92980839c Add securitycheck and bump deps where needed (#1745)
Address:
- github.com/docker/docker / github.com/containerd/containerd
- CVE-2022-23471, CVE-2023-25153, CVE-2023-25173, CVE-2023-28840,
CVE-2023-28841, CVE-2023-28842
- github.com/moby/moby
  - GHSA-vp35-85q5-9f25
- google.golang.org/protobuf
  - CVE-2023-24535, GHSA-hw7c-3rfg-p46j
2023-05-11 04:27:31 +02:00

44 lines
663 B
Go

package logrus
import (
"bytes"
"sync"
)
var (
bufferPool BufferPool
)
type BufferPool interface {
Put(*bytes.Buffer)
Get() *bytes.Buffer
}
type defaultPool struct {
pool *sync.Pool
}
func (p *defaultPool) Put(buf *bytes.Buffer) {
p.pool.Put(buf)
}
func (p *defaultPool) Get() *bytes.Buffer {
return p.pool.Get().(*bytes.Buffer)
}
// SetBufferPool allows to replace the default logrus buffer pool
// to better meets the specific needs of an application.
func SetBufferPool(bp BufferPool) {
bufferPool = bp
}
func init() {
SetBufferPool(&defaultPool{
pool: &sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)
},
},
})
}