Commit 6fd2fb13 authored by Frederick Akalin's avatar Frederick Akalin Committed by Han-Wen Nienhuys

Make BufferPool.AllocBuffer() return a buffer of the correct size.

Fixes #39.
parent 60423690
...@@ -78,7 +78,7 @@ func (p *bufferPoolImpl) AllocBuffer(size uint32) []byte { ...@@ -78,7 +78,7 @@ func (p *bufferPoolImpl) AllocBuffer(size uint32) []byte {
pages := sz / PAGESIZE pages := sz / PAGESIZE
b := p.getPool(pages).Get().([]byte) b := p.getPool(pages).Get().([]byte)
return b return b[:size]
} }
func (p *bufferPoolImpl) FreeBuffer(slice []byte) { func (p *bufferPoolImpl) FreeBuffer(slice []byte) {
......
package fuse
import (
"testing"
)
func TestBufferPool(t *testing.T) {
bp := NewBufferPool()
size := 1500
buf := bp.AllocBuffer(uint32(size))
if len(buf) != size {
t.Errorf("Expected buffer of %d bytes, got %d bytes", size, len(buf))
}
bp.FreeBuffer(buf)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment