|  | @@ -1,6 +1,7 @@
 | 
											
												
													
														|  |  package kcp
 |  |  package kcp
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import (
 |  |  import (
 | 
											
												
													
														|  | 
 |  | +	"github.com/v2ray/v2ray-core/common"
 | 
											
												
													
														|  |  	"github.com/v2ray/v2ray-core/common/alloc"
 |  |  	"github.com/v2ray/v2ray-core/common/alloc"
 | 
											
												
													
														|  |  	"github.com/v2ray/v2ray-core/common/serial"
 |  |  	"github.com/v2ray/v2ray-core/common/serial"
 | 
											
												
													
														|  |  )
 |  |  )
 | 
											
										
											
												
													
														|  | @@ -20,6 +21,7 @@ const (
 | 
											
												
													
														|  |  )
 |  |  )
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  type ISegment interface {
 |  |  type ISegment interface {
 | 
											
												
													
														|  | 
 |  | +	common.Releasable
 | 
											
												
													
														|  |  	ByteSize() int
 |  |  	ByteSize() int
 | 
											
												
													
														|  |  	Bytes([]byte) []byte
 |  |  	Bytes([]byte) []byte
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
										
											
												
													
														|  | @@ -54,6 +56,10 @@ func (this *DataSegment) ByteSize() int {
 | 
											
												
													
														|  |  	return 2 + 1 + 1 + 4 + 4 + 4 + 4 + 2 + this.Data.Len()
 |  |  	return 2 + 1 + 1 + 4 + 4 + 4 + 4 + 2 + this.Data.Len()
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +func (this *DataSegment) Release() {
 | 
											
												
													
														|  | 
 |  | +	this.Data.Release()
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  type ACKSegment struct {
 |  |  type ACKSegment struct {
 | 
											
												
													
														|  |  	Conv            uint16
 |  |  	Conv            uint16
 | 
											
												
													
														|  |  	Opt             SegmentOption
 |  |  	Opt             SegmentOption
 | 
											
										
											
												
													
														|  | @@ -81,6 +87,8 @@ func (this *ACKSegment) Bytes(b []byte) []byte {
 | 
											
												
													
														|  |  	return b
 |  |  	return b
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +func (this *ACKSegment) Release() {}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  type TerminationSegment struct {
 |  |  type TerminationSegment struct {
 | 
											
												
													
														|  |  	Conv uint16
 |  |  	Conv uint16
 | 
											
												
													
														|  |  	Opt  SegmentOption
 |  |  	Opt  SegmentOption
 | 
											
										
											
												
													
														|  | @@ -96,6 +104,8 @@ func (this *TerminationSegment) Bytes(b []byte) []byte {
 | 
											
												
													
														|  |  	return b
 |  |  	return b
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +func (this *TerminationSegment) Release() {}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  func ReadSegment(buf []byte) (ISegment, []byte) {
 |  |  func ReadSegment(buf []byte) (ISegment, []byte) {
 | 
											
												
													
														|  |  	if len(buf) <= 12 {
 |  |  	if len(buf) <= 12 {
 | 
											
												
													
														|  |  		return nil, nil
 |  |  		return nil, nil
 |