Fix null termination in stringbuilder and refactor

I'm not sure how you'll feel about all of these changes, but I feel they make the code simpler and safer.  Let me know if you want to discuss anything.

COMMIT COMMENTS BELOW
===============================================================

Fix an issue in stringbuilder whereby it was not null terminating
strings correctly.  In applying this fix, a number of vaguely related
changes are made.

stringbuilder
 - Fill string buffer with null on creation and resize to ensure any
   characters not written to the string are null, and the buffer is
   therefore always null terminated.
 - Make sb_reset a function, not a macro
 - Add sb_resize function as reusuable and consistent means of resizing
   buffer
 - Add sb_double_size as a convenience function to double the buffer size
 - Make sb_append_ch a function, not a macro
 - Change resize strategy in sb_append_strn to keep doubling the new
   buffer size until the string to be appended will fit

stringbuilder_test
 - Add check of cstring's length to _assert_sb_stats
 - Modify tests to match new code