mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-03 07:45:29 -05:00
api doc
This commit is contained in:
@@ -35,6 +35,8 @@ func init() {
|
||||
|
||||
// GetPool returns a sync.Pool that generates bytes array with at least the given size.
|
||||
// It may return nil if no such pool exists.
|
||||
//
|
||||
// v2ray:api:stable
|
||||
func GetPool(size int32) *sync.Pool {
|
||||
for idx, ps := range poolSize {
|
||||
if size <= ps {
|
||||
@@ -45,6 +47,8 @@ func GetPool(size int32) *sync.Pool {
|
||||
}
|
||||
|
||||
// Alloc returns a byte slice with at least the given size. Minimum size of returned slice is 2048.
|
||||
//
|
||||
// v2ray:api:stable
|
||||
func Alloc(size int32) []byte {
|
||||
pool := GetPool(size)
|
||||
if pool != nil {
|
||||
@@ -54,6 +58,8 @@ func Alloc(size int32) []byte {
|
||||
}
|
||||
|
||||
// Free puts a byte slice into the internal pool.
|
||||
//
|
||||
// v2ray:api:stable
|
||||
func Free(b []byte) {
|
||||
size := int32(cap(b))
|
||||
b = b[0:cap(b)]
|
||||
|
||||
Reference in New Issue
Block a user