refactor: udp

This commit is contained in:
世界
2022-06-09 21:16:42 +08:00
parent cd466f05d3
commit 637a8b6ed5
23 changed files with 231 additions and 127 deletions

View File

@ -6,9 +6,15 @@ import (
"errors"
"math/bits"
"sync"
"github.com/sagernet/sing/common/buf"
)
var DefaultAllocator = NewAllocator()
var defaultAllocator = NewAllocator()
func init() {
buf.DefaultAllocator = defaultAllocator
}
// Allocator for incoming frames, optimized to prevent overwriting after zeroing
type Allocator struct {

View File

@ -13,9 +13,9 @@ const (
)
func Get(size int) []byte {
return DefaultAllocator.Get(size)
return defaultAllocator.Get(size)
}
func Put(buf []byte) error {
return DefaultAllocator.Put(buf)
return defaultAllocator.Put(buf)
}