github.com/geph-official/geph2@v0.22.6-0.20210211030601-f527cb59b0df/libs/fastudp/pool.go (about) 1 package fastudp 2 3 import "sync" 4 5 var bufPool = &sync.Pool{ 6 New: func() interface{} { 7 return make([]byte, 2048) 8 }, 9 } 10 11 func malloc(n int) []byte { 12 return bufPool.Get().([]byte)[:n] 13 } 14 15 func free(bts []byte) { 16 bufPool.Put(bts[:2048]) 17 }