Do leaks really matter in this kind of program? Sure, you're going to leak; how much? Sometimes with this type of code you let it leak, and it ends up simpler otherwise. How much leakage are we talking about here?
I only ask because I was talking to someone a year ago who did not realize that the OS reclaimed all the storage a program leaked when the program exited :-) The poor guy was getting tangled up in knots over a 4k leak which in the long run really was of not importance ...
ron