2 ms·
In C the way to solve this is to look at the man page for the function and see what they say about memory allocation. There is no magic involved.
by coliveira 4y ago
In C the way to solve this is to look at the man page for the function and see what they say about memory allocation. There is no magic involved.
- c-smile 4y agoDocumentation solves just one problem: to free or not to free. But there are performance, security and other issues. What if it is significantly more performant for getenv() (or whatever) to fetch needed data using alloca (on stack, with fallback to heap/malloc)? Returning naked pointer is far from being flexible really.