MFC r212365, r212367:
r212365: Refactor sbuf code so that most uses of sbuf_extend() are in
a new sbuf_put_byte(). This makes it easier to add drain
functionality when a buffer would overflow as there are fewer code
points.
r212367: Add drain functionality to sbufs. The drain is a function
that is called when the sbuf internal buffer is filled. For kernel
sbufs with a drain, the internal buffer will never be expanded. For
userland sbufs with a drain, the internal buffer may still be expanded
by sbuf_[v]printf(3).
Sbufs now have three basic uses:
1) static string manipulation. Overflow is marked.
2) dynamic string manipulation. Overflow triggers string growth.
3) drained string manipulation. Overflow triggers draining.
In all cases the manipulation is 'safe' in that overflow is detected and
managed.
Note that r212367 had to be minorly re-implemented to dynamically
allocate space for a function pointer, a void * argument, and an int
error, to not break the ABI/KBI.
git-svn-id: svn://svn.freebsd.org/base/stable/8@222574
ccf9f872-aa2e-dd11-9fc8-
001c23d0bc1f