mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-20 01:45:00 +03:00
Update sing-box core, refactor MASQUE, update XHTTP
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
package masque
|
||||
|
||||
import "sync"
|
||||
|
||||
type NetBuffer struct {
|
||||
capacity uint32
|
||||
buf sync.Pool
|
||||
}
|
||||
|
||||
func (n *NetBuffer) Get() []byte {
|
||||
return *n.buf.Get().(*[]byte)
|
||||
}
|
||||
|
||||
func (n *NetBuffer) Put(buf []byte) {
|
||||
if cap(buf) != int(n.capacity) {
|
||||
return
|
||||
}
|
||||
n.buf.Put(&buf)
|
||||
}
|
||||
|
||||
func NewNetBuffer(capacity uint32) *NetBuffer {
|
||||
if capacity == 0 {
|
||||
panic("capacity must be greater than 0")
|
||||
}
|
||||
return &NetBuffer{
|
||||
capacity: capacity,
|
||||
buf: sync.Pool{
|
||||
New: func() interface{} {
|
||||
b := make([]byte, capacity)
|
||||
return &b
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user