Pergunta de entrevista da empresa IBM

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