I came across the function getenv from c recently, which takes an environment variable as argument and returns the corresponding path.
const char * path = getenv("HOME");
....
This got me thinking if this could cause a memory leak. Because the function returns a value which has to be dynamically allocated because the value exists after the function is out of scope. It would be deallocated after the function call went after scope if it was allocated on the function call stack right? If that's the case should I call free() or an appropriate deallocator function to avoid memory leak? If it's not dynamically allocated, then is it something like an anonymous constant value? I am sort of confused on how this works and this sort of function calls are very common in C that's why I am sort of worried about memory leaks and such.