返回下一个可用的[]byte,自动增长空间
(n int)
| 30 | |
| 31 | // 返回下一个可用的[]byte,自动增长空间 |
| 32 | func (b *ByteBuffer) Use(n int) []byte { |
| 33 | b.offset += n |
| 34 | if b.offset > b.quota { |
| 35 | panic("Quota limit exceeded!") // 对忘记调用Reset的保护 |
| 36 | } |
| 37 | if b.offset > len(b.buf) { |
| 38 | b.buf = append(b.buf, make([]byte, (b.offset-len(b.buf))*2)...) |
| 39 | } |
| 40 | return b.buf[b.offset-n : b.offset] |
| 41 | } |
| 42 | |
| 43 | // 返回所有Use调用过的[]byte |
| 44 | func (b *ByteBuffer) Bytes() []byte { |
no outgoing calls