The output buffer growth algorithm had a couple of issues:
a) An off-by-one error in the initial size check, which uses '>='. This error was safe, but could cause us to reallocate when there was no need.
b) An inconsistency between the initial size check (>=) and the post-doubling check (>). The latter was somewhat obscured by the swapped operands.
c) There would be many reallocs with an initially-small buffer. Add a little initialization hysteresis.
What's the meaning of the magic number 100? Generally we should make it configurable or at least we should give a name to it.