diff options
Diffstat (limited to 'slab.go')
| -rw-r--r-- | slab.go | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/slab.go b/slab.go deleted file mode 100644 index 2210c9f..0000000 --- a/slab.go +++ /dev/null @@ -1,25 +0,0 @@ -package dhtsearch - -// Slab memory allocation - -// Initialise the slab as a channel of blocks, allocating them as required and -// pushing them back on the slab. This reduces garbage collection. -type slab chan []byte - -func newSlab(blockSize int, numBlocks int) slab { - s := make(slab, numBlocks) - for i := 0; i < numBlocks; i++ { - s <- make([]byte, blockSize) - } - return s -} - -func (s slab) Alloc() (x []byte) { - return <-s -} - -func (s slab) Free(x []byte) { - // Check we are using the right dimensions - x = x[:cap(x)] - s <- x -} |
