I agree in theory. In practice, programs evolve and code gets reused. Omitting free calls because you expect the code to exit rapidly is a recipe for disaster once you change your mind later. It's much easier to put this stuff in from the start than it is to retrofit it later.
> That's acceptable for a command-line program that will terminate quickly
No, it isn't; you don't know how quickly the program will terminate, in general, and it only takes one program running longer than you expect to eat a horrible amount of RAM.
JoachimSchipper|14 years ago
databus|14 years ago
My strategy in c is as soon as I write the word "malloc" I figure out where to put the free.
mikeash|14 years ago
derleth|14 years ago
No, it isn't; you don't know how quickly the program will terminate, in general, and it only takes one program running longer than you expect to eat a horrible amount of RAM.
leif|14 years ago