1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-29 21:45:21 -05:00

chunk stream in vmess

This commit is contained in:
v2ray
2016-02-01 12:22:29 +01:00
parent 6c7a9586d0
commit d3ff2b3698
21 changed files with 225 additions and 139 deletions

View File

@@ -9,19 +9,6 @@ const (
DefaultOffset = 16
)
func Release(buffer *Buffer) {
if buffer != nil {
buffer.Release()
}
}
func Len(buffer *Buffer) int {
if buffer == nil {
return 0
}
return buffer.Len()
}
// Buffer is a recyclable allocation of a byte array. Buffer.Release() recycles
// the buffer into an internal buffer pool, in order to recreate a buffer more
// quickly.
@@ -34,6 +21,9 @@ type Buffer struct {
// Release recycles the buffer into an internal buffer pool.
func (b *Buffer) Release() {
if b == nil {
return
}
b.pool.free(b)
b.head = nil
b.Value = nil
@@ -96,6 +86,9 @@ func (b *Buffer) SliceBack(offset int) *Buffer {
// Len returns the length of the buffer content.
func (b *Buffer) Len() int {
if b == nil {
return 0
}
return len(b.Value)
}