IBM Interview Question

How to avoid a memory leak in C? (only asked because I mentioned learning C)