release buffer if payload becomes small

pull/981/head
Darien Raymond 2018-03-16 22:32:03 +07:00
parent feb421d9e1
commit b2d9364cb5
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 3 additions and 0 deletions

View File

@ -47,6 +47,9 @@ func (r *BytesToBufferReader) ReadMultiBuffer() (MultiBuffer, error) {
if nBytes == len(r.buffer) && nBytes < xlSize {
freeBytes(r.buffer)
r.buffer = newBytes(uint32(nBytes) + 1)
} else if nBytes < Size {
freeBytes(r.buffer)
r.buffer = nil
}
return mb, nil
}