Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with bytes.ErrTooLarge.
// If we read, this affects buf.off, which is good to test. readBytes, _ := buf.Read(tmp) buf.Grow(growLen) yBytes := bytes.Repeat(y, growLen) // Check no allocation occurs in write, as long as we're single-threaded.
Grow is referenced in 1 repositorygithub.com/syndtr/goleveldb
- 1 reference in leveldb/util/buffer_test.go