OutMessage.GrowNoZero

geesefs-0-30-9
Aaron Jacobs 2016-12-19 13:01:45 +11:00
parent a7c1a1474a
commit d1ed507a5a
1 changed files with 12 additions and 1 deletions

View File

@ -81,7 +81,18 @@ func (m *OutMessage) Grow(n int) (p unsafe.Pointer)
// GrowNoZero is equivalent to Grow, except the new segment is not zeroed. Use
// with caution!
func (m *OutMessage) GrowNoZero(n int) (p unsafe.Pointer)
func (m *OutMessage) GrowNoZero(n int) (p unsafe.Pointer) {
// Will we overflow the buffer?
o := m.payloadOffset
if len(m.payload)-o < n {
return
}
p = unsafe.Pointer(uintptr(unsafe.Pointer(&m.payload)) + uintptr(o))
m.payloadOffset = o + n
return
}
// ShrinkTo shrinks m to the given size. It panics if the size is greater than
// Len() or less than OutMessageHeaderSize.