It depends. If I'm writing a library, it's bare pointers. If I'm writing something not a library that's big enough, I'll use a struct {size_t length; char* string;} where the length is the string length, and string contains (length) characters + a nul byte. I might even mix in allocation data for the total allocated size of the buffer if it's important enough.
Simple to implement and use (and also backwards compatible), provided you have a library of common functions for allocating, copying, etc.
If I'm size constrained, I'll consider uint16_t for the length field. If I'm REALLY size constrained, I'll use a VLQ [1] for the length field and take the slight performance hit.
Simple to implement and use (and also backwards compatible), provided you have a library of common functions for allocating, copying, etc.
If I'm size constrained, I'll consider uint16_t for the length field. If I'm REALLY size constrained, I'll use a VLQ [1] for the length field and take the slight performance hit.
[1] https://github.com/kstenerud/vlq/blob/master/vlq-specificati...