[th/str-buf-stack-allocated] glib-aux: add support for starting with stack-allocated buffer in NMStrBuf
Allow to initialize NMStrBuf
with an externally allocated array.
Usually that would be a stack buffer. If the NMStrBuf
grows beyond
the size of that initial buffer, then it would switch using malloc.
The idea is to support the common case where the result is small enough to fit on the stack.
I always wanted to do such optimization because the main purpose of
NMStrBuf
is to put it on the stack and ad-hoc construct a string.
I just figured, it would be complicate the implementation and add
a runtime overhead. Now I think the implementation not complicated
and the usage convenient.