Remove some memory of the given size from the current write buffer
(offset int, size int)
| 132 | |
| 133 | // Remove some memory of the given size from the current write buffer |
| 134 | func (b *Buffer) Remove(offset int, size int) { |
| 135 | if (offset + size) > len(b.data) { |
| 136 | panic("invalid offset & size") |
| 137 | } |
| 138 | |
| 139 | copy(b.data[offset:], b.data[offset+size:]) |
| 140 | b.size -= size |
| 141 | if b.offset >= (offset + size) { |
| 142 | b.offset -= size |
| 143 | } else if b.offset >= offset { |
| 144 | b.offset -= b.offset - offset |
| 145 | if b.offset > b.size { |
| 146 | b.offset = b.size |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | // Reserve memory of the given capacity in the current write bufferb |
| 152 | func (b *Buffer) Reserve(capacity int) { |