Close releases all memory allocated by this buffer.
()
| 19 | |
| 20 | // Close releases all memory allocated by this buffer. |
| 21 | func (b *WriteBuffer) Close() { |
| 22 | b.mu.Lock() |
| 23 | defer b.mu.Unlock() |
| 24 | |
| 25 | if b.alloc != nil { |
| 26 | for _, s := range b.inner.Slices { |
| 27 | b.alloc.releaseChunk(s) |
| 28 | } |
| 29 | |
| 30 | b.alloc = nil |
| 31 | } |
| 32 | |
| 33 | b.inner.invalidate() |
| 34 | } |
| 35 | |
| 36 | // MakeContiguous ensures the write buffer consists of exactly one contiguous single slice of the provided length |
| 37 | // and returns the slice. |