3 ms·
Hoping someone can educate me, what are the advantages of having the last member of strbuf_t be a variable length array (char cstr[]) instead of just a char*?
by gkfasdfasdf 4y ago
Hoping someone can educate me, what are the advantages of having the last member of strbuf_t be a variable length array (char cstr[]) instead of just a char*?
- ComputerGuru 4y agoYou can store the string as part of the same heap/stack allocation rather than as a separate allocation.
- ksherlock 4y agoWith inline data, only one malloc is needed for the buffer housekeeping and character data. It's also probably slightly better for cache performance since the housekeeping data and string data are together.
- gkfasdfasdf 4y agoAh I see. If you want to refer to a string that was not part of this allocation you would use the other str_t type,