Release the node that has been read. b.flush == nil indicates that this LinkBuffer is created by LinkBuffer.Slice
()
| 272 | // Release the node that has been read. |
| 273 | // b.flush == nil indicates that this LinkBuffer is created by LinkBuffer.Slice |
| 274 | func (b *UnsafeLinkBuffer) Release() (err error) { |
| 275 | for b.read != b.flush && b.read.Len() == 0 { |
| 276 | b.read = b.read.next |
| 277 | } |
| 278 | for b.head != b.read { |
| 279 | node := b.head |
| 280 | b.head = b.head.next |
| 281 | node.Release() |
| 282 | } |
| 283 | for i := range b.caches { |
| 284 | free(b.caches[i]) |
| 285 | b.caches[i] = nil |
| 286 | } |
| 287 | b.caches = b.caches[:0] |
| 288 | if b.cachePeek != nil { |
| 289 | free(b.cachePeek) |
| 290 | b.cachePeek = nil |
| 291 | } |
| 292 | return nil |
| 293 | } |
| 294 | |
| 295 | // ReadString implements Reader. |
| 296 | func (b *UnsafeLinkBuffer) ReadString(n int) (s string, err error) { |