Spent a few more hours on AutoTrace. Martin had fixed most memory leaks, but there were still a few more present. Now there are only 6 left. At least this number is independent of the input image, which probably means that they're somewhere outside the actual tracing or curve fitting code and hopefully easier to find.
I also discovered that the number of mallocs I mentioned yesterday wasn't correct. Some mallocs were counted twice. The real number of mallocs for that image is 1 127 388. I've now replaced the hacked malloc/free/realloc counting code that only counted calls through the macros autotrace uses in most places with a cleaner implementation that uses the hooks provided by glibc. That way I really get all calls and it requires far fewer changes in the sources.
Still, the code is decidedly ugly. In this particular case, open source doesn't mean better code quality. These memory leaks probably weren't a problem in limn which was 'only' a command line tool that was executed over and over again. But some people want to use AutoTrace as a library someday, so they have to be eliminated.
AutoTrace is in what you might call the 'bugly duckling' phase of development. It's buggy and maybe a bit cumbersome to use and somewhat limited in what it already can do, but it has the potential to someday turn into a beautiful swan. Of course even with a swan gliding majestically through the water you normally don't see the hectic paddling underneath...
This evening some guy started singing a capella (does one say that in English?) in the street right in front of my window. Another guy was filming him with a video camera. His intended audience were apparantly some peope in a flat above mine.
Among others he sang Tom Jones' "Sex Bomb", Sinatra's "My Way" and Presley's "In the Ghetto", some of them slightly modified. He was quite a good singer good even.