|
@ -35,12 +35,10 @@ func getSlotPool(size int) *sync.Pool { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Allocate(size int) []byte { |
|
|
func Allocate(size int) []byte { |
|
|
return make([]byte, size) |
|
|
|
|
|
slab := *getSlotPool(size).Get().(*[]byte) |
|
|
slab := *getSlotPool(size).Get().(*[]byte) |
|
|
return slab[:size] |
|
|
return slab[:size] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Free(buf []byte) { |
|
|
func Free(buf []byte) { |
|
|
return |
|
|
|
|
|
getSlotPool(cap(buf)).Put(&buf) |
|
|
getSlotPool(cap(buf)).Put(&buf) |
|
|
} |
|
|
} |