3 ms·
IMHO that does not solve the main problem, that is individual lifetime management. I've seen many libs using this style of strings, not convinced by the practi
by stephc_int13 4y ago
IMHO that does not solve the main problem, that is individual lifetime management.
I've seen many libs using this style of strings, not convinced by the practicality.
- nickff 4y agoWhat is "individual lifetime management"?
- klodolph 4y agoIt sounds like you’re rephrasing part of my comment back to me, or maybe I’m misinterpreting what you’re saying. If you’re not convinced of the practicality, it sounds like you are simply not convinced of the practicality of doing string processing in C at all, which is a fair view point. String processing in C is somewhat a minefield. Libraries like Git’s strbuf are very effective relative to other solutions in C, but lack safety relative to other languages.
- stephc_int13 4y agoNo, I simply am using a different approach, still in C, where strings are simple char*, null-terminated, nothing hidden with magic fields above the base address of the string. The trick is to pass an allocator (or container) to string handling functions. If/when I want to get rid of all the garbage I reset the container/allocator.
- klodolph 4y agoYeah, you should have just said that in the first place. I’ve seen similar approaches, e.g. with APR pools, and if your application can work within those restrictions, it’s very convenient.