Tag Archives: C

Adventures in non-deterministic code (Always initialized your structs!)

I've been working on an old code base lately. It's a relatively simple data in/data out, kinda program. But It's also a bit messy, written in C using outdated techniques, and suffers from memory leaks. So I am going through the process of cleaning it up and porting it to C++ so the code can be made simpler and easier to manage.

Being that I didn't write the original code, my first thought was to create some sort of regression tests. My plan was simple. Run the code on a bunch of varied input files, and save the output. Now, every subsequent run I can just diff the results with the "known good" ones and I should be good to go... right?

Sadly, this was not the case.