| 76 | } |
| 77 | |
| 78 | type buffer struct { |
| 79 | refs atomic.Int32 |
| 80 | data []byte |
| 81 | |
| 82 | // rootBuf is the buffer responsible for returning origData to the pool |
| 83 | // once the reference count drops to 0. |
| 84 | // |
| 85 | // When a buffer is split, the new buffer inherits the rootBuf of the |
| 86 | // original and increments the root's reference count. For the |
| 87 | // initial buffer (the root), this field points to itself. |
| 88 | rootBuf *buffer |
| 89 | |
| 90 | // The following fields are only set for root buffers. |
| 91 | origData *[]byte |
| 92 | pool BufferPool |
| 93 | } |
| 94 | |
| 95 | func newBuffer() *buffer { |
| 96 | return bufferObjectPool.Get().(*buffer) |
nothing calls this directly
no outgoing calls
no test coverage detected