Releases a buffer obtained by getBuffer() or getBufferSetLength(), and sets its length.
If newLength == -1, the buffer is treated as 0 terminated.