The main() function

The first thing that runs is, of course, main(). You'll notice that my main() functions tend to be very short—handle command-line processing (always with optproc()), call a few initialization functions (if required), and then start processing.

In general, I try to deallocate any memory that I've allocated throughout the course of the program. This might seem like overkill because the operating system cleans up your resources when you drop off the end of main() (or call exit()). Why bother to clean up after yourself? Some of the subsystems might find their way into other projects—and they might need to start up and shut down many times during the life of the process. Not being sloppy about the cleanup phase makes my life just that much easier when I reuse code. It also helps when using tools like the debug malloc() library.