Skip to content
File

Blob: util/buffer_pool.go

go28 lines
1package util
2 
3import (
4 "net/http/httputil"
5 
6 pool "github.com/libp2p/go-buffer-pool"
7)
8 
9type BufferPool struct {
10 bufferSize int
11}
12 
13var _ httputil.BufferPool = (*BufferPool)(nil)
14 
15func NewBufferPool(size int) *BufferPool {
16 return &BufferPool{
17 bufferSize: size,
18 }
19}
20 
21func (b *BufferPool) Get() []byte {
22 return pool.Get(b.bufferSize)
23}
24 
25func (b *BufferPool) Put(buf []byte) {
26 pool.Put(buf)
27}