mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 20:37:40 +03:00
31 lines
561 B
Go
31 lines
561 B
Go
package buf
|
|
|
|
import "github.com/sagernet/sing/common"
|
|
|
|
func LenMulti(buffers []*Buffer) int {
|
|
var n int
|
|
for _, buffer := range buffers {
|
|
n += buffer.Len()
|
|
}
|
|
return n
|
|
}
|
|
|
|
func ToSliceMulti(buffers []*Buffer) [][]byte {
|
|
return common.Map(buffers, func(it *Buffer) []byte {
|
|
return it.Bytes()
|
|
})
|
|
}
|
|
|
|
func CopyMulti(toBuffer []byte, buffers []*Buffer) int {
|
|
var n int
|
|
for _, buffer := range buffers {
|
|
n += copy(toBuffer[n:], buffer.Bytes())
|
|
}
|
|
return n
|
|
}
|
|
|
|
func ReleaseMulti(buffers []*Buffer) {
|
|
for _, buffer := range buffers {
|
|
buffer.Release()
|
|
}
|
|
}
|