mirror of
https://github.com/lkmio/lkm.git
synced 2025-10-21 22:29:29 +08:00
测试合并写
This commit is contained in:
@@ -25,6 +25,8 @@ type MemoryPool interface {
|
||||
|
||||
// FreeTail 从尾部释放指定大小内存
|
||||
FreeTail()
|
||||
|
||||
Data() ([]byte, []byte)
|
||||
}
|
||||
|
||||
func NewMemoryPool(capacity int) MemoryPool {
|
||||
@@ -135,3 +137,12 @@ func (m *memoryPool) FreeTail() {
|
||||
m.tail = m.capacity
|
||||
}
|
||||
}
|
||||
|
||||
func (m *memoryPool) Data() ([]byte, []byte) {
|
||||
if m.tail <= m.head {
|
||||
return m.data[m.head:], m.data[:m.tail]
|
||||
} else {
|
||||
return m.data[m.head:m.tail], nil
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user