Update strbuffer append logic.

Update actual data length of contents in buffer when appending.
Fix calculation of new buffer size when growing the buffer.