mirror of
https://github.com/restic/restic.git
synced 2024-12-24 16:54:00 +00:00
20 lines
267 B
Go
20 lines
267 B
Go
|
package crypto
|
||
|
|
||
|
import "sync"
|
||
|
|
||
|
const defaultBufSize = 2048
|
||
|
|
||
|
var bufPool = sync.Pool{
|
||
|
New: func() interface{} {
|
||
|
return make([]byte, defaultBufSize)
|
||
|
},
|
||
|
}
|
||
|
|
||
|
func getBuffer() []byte {
|
||
|
return bufPool.Get().([]byte)
|
||
|
}
|
||
|
|
||
|
func freeBuffer(buf []byte) {
|
||
|
bufPool.Put(buf)
|
||
|
}
|