4 ms·
The Better String Library (aka batting, not to be confused with COM’s BSTR) is fairly nice: https://bstring.sourceforge.net/ https://bstring.sourceforge.net/
by MarkSweep 2y ago
The Better String Library (aka batting, not to be confused with COM’s BSTR) is fairly nice:
https://bstring.sourceforge.net/ https://bstring.sourceforge.net/
The string keeps track of the buffer size and how much has been used, allowing allocations to be somewhat amortized. The string buffer itself is zero-terminated for easy interop with code that expects standard C strings.
struct tagbstring {
int mlen;
int slen;
unsigned char * data;
};
I used it on a microcontroller where I wanted something small and simple. The main missing feature is the lack of a small-string optimization like some implementations of std::string have. (Before anyone complains about this string type being too inefficient for a microcontroller, I had 1 MB of flash and 192KB of RAM, so I was not super constrained for resources)