I was just wondering, in the following scenarion, is the memory used by 'stringvar' freed after method1 is done executing?
// Just some method
void method2(char* str)
{
// Allocate 10 characters for str
str = malloc(10 * sizeof(char));
}
// Just another method
void method1()
{
char* stringvar;
method2(stringvar);
// Is the memory freed hereafter, or do I need to call free()?
}
I ask, because if I put a 'free(stringvar)' at the end of method1, I get a warning that stringvar is unitialized inside method1 (which is true).