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.

Read More...

How not to maintain an API

So I've been working on my graphing code for EDB. I was eventually able to create a Qt widget that natively renders a graphviz graph layout. It actually works quite nicely, you can create an ordinary Graphviz graph either in memory or from a file like usual. The code can simply create a "GraphWidget" and the code will display the graph perfectly (there are some constructs that it doesn't support, but the basics are there) with nice things such as zooming and rotating.

All of this works great, except for the fact that Graphviz decided to change some of the structures used to represent the laid-out graph.

Read More...