help understanding free and memory leaks
Hello,
If I understood correctly (and it wouldn't be the first time if I did not), when allocating a local array or struct inside a function one should free it before finishing the function, in order to avoid memory leaks. Am I correct? This may become a huge issue with programs with a GUI, which stay open for a long time and repeatedly call that function.
How about local variables defined within a function? I am guessing it is not a big deal to free them, because they do not get allocated a contiguous block of memory. However, is it considered a "good programming habit" to free local variables? Does it even make sense to think of freeing a local variable?
Thank you very much for you help,
mc61