C how to free malloc'ed memory when program can encounter error and exit at different places?

If func1() or func2() is going to call exit(1) on some condition, you don't have worry about freeing memory for foo or bar as the operating sytem will typically do clean up once the process exits.

If a function calls exit you don't have to clean your memory usage at all, it will be freed by the OS. But if you need to release other resources (e.g. Lock file, clean temp files, ...) then you can use the atexit function or if you use the gnu libc the on_exit function to do the job.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions