pool.go 299 B

1234567891011121314151617181920212223
  1. // +build !confonly
  2. package quic
  3. import (
  4. "sync"
  5. "github.com/v2fly/v2ray-core/v4/common/bytespool"
  6. )
  7. var pool *sync.Pool
  8. func init() {
  9. pool = bytespool.GetPool(2048)
  10. }
  11. func getBuffer() []byte {
  12. return pool.Get().([]byte)
  13. }
  14. func putBuffer(p []byte) {
  15. pool.Put(p) // nolint: staticcheck
  16. }