WIP: [th/strbuf] own string-buffer implementation
I think GString
is not as great as it should be. The basic functionality, for what we mostly use GString, is easy to implement.
The point of NMStrBuf
is, that we can build API around it. Meaning, we have various to-string functions like nmp_object_to_string()
. Currently, these to-string function force one or another way how to construct strings on the user. For example, nmp_object_to_string()
uses a buffer and a fixed length. That is efficient as it requires not re-alloc or may avoid heap allocation. However, it's hard for the caller got choose the right buffer size. Either the string gets truncated or the buffer is too large. If these to-string functions would accept a NMStrBuf
, the caller can decide whether the string should grow dynamically (heap-allocated), or whether it should use a static buffer, or whether the maximum length should be limited, or whether the action should avoid leaking secrets (explicit-bzero). Not all of these functionalities (using a static-buffer or a maximum lenght) are implemented yet. However they could easily be added -- without modifying the to-string functions that write to the buffer.