1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-11-23 12:02:58 -05:00

migrate int to int32

This commit is contained in:
Darien Raymond
2018-04-02 20:00:50 +02:00
parent 4de3f1adc1
commit 08dab81eb2
30 changed files with 100 additions and 104 deletions

View File

@@ -66,7 +66,7 @@ func ReadAllToBytes(reader io.Reader) ([]byte, error) {
type MultiBuffer []*Buffer
// NewMultiBufferCap creates a new MultiBuffer instance.
func NewMultiBufferCap(capacity int) MultiBuffer {
func NewMultiBufferCap(capacity int32) MultiBuffer {
return MultiBuffer(make([]*Buffer, 0, capacity))
}
@@ -93,7 +93,7 @@ func (mb MultiBuffer) Copy(b []byte) int {
for _, bb := range mb {
nBytes := copy(b[total:], bb.Bytes())
total += nBytes
if nBytes < bb.Len() {
if int32(nBytes) < bb.Len() {
break
}
}
@@ -137,8 +137,8 @@ func (mb *MultiBuffer) Write(b []byte) {
}
// Len returns the total number of bytes in the MultiBuffer.
func (mb MultiBuffer) Len() int {
size := 0
func (mb MultiBuffer) Len() int32 {
size := int32(0)
for _, b := range mb {
size += b.Len()
}
@@ -176,10 +176,10 @@ func (mb MultiBuffer) ToNetBuffers() net.Buffers {
// SliceBySize splits the beginning of this MultiBuffer into another one, for at most size bytes.
func (mb *MultiBuffer) SliceBySize(size int32) MultiBuffer {
slice := NewMultiBufferCap(10)
sliceSize := 0
sliceSize := int32(0)
endIndex := len(*mb)
for i, b := range *mb {
if int32(b.Len()+sliceSize) > size {
if b.Len()+sliceSize > size {
endIndex = i
break
}