Get get a free memory buffer.
()
| 67 | |
| 68 | // Get get a free memory buffer. |
| 69 | func (p *Pool) Get() (b *Buffer) { |
| 70 | p.lock.Lock() |
| 71 | if b = p.free; b == nil { |
| 72 | p.grow() |
| 73 | b = p.free |
| 74 | } |
| 75 | p.free = b.next |
| 76 | p.lock.Unlock() |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | // Put put back a memory buffer to free. |
| 81 | func (p *Pool) Put(b *Buffer) { |