Debugging Pro-Tip: Malloc() Errors

On Friday, I spent a number of hours trying to run down an error in a fairly substantial piece of code. All I really knew was that I kept getting an error that said something like: *** glibc detected *** ./my_program: malloc(): memory corruption: 0x0000000002296980 *** When I pushed this piece of code through gdb, I

Patterns: Boundary Check

A wise quote: When it goes without saying, someone should probably say it. This is one of the better known patterns out there, but it still bears repeating. The boundaries for integers When you're working with a range of integers (for example, human age range could be between 0 and 135), we have two obvious boundary points

Patterns: “Classes” in C

Encapsulation is a key aspect of the Object Oriented Programming model, and for good reason. We have an easier time grasping units which do one thing than hundreds of independent operations and objects that can do a number of things. While C does not contain the class descriptor found in C++ or Java, we

Linux + C – Concepts of Debugging

It's almost time to talk about that most important aspect of programming - testing. However, before we start talking about the tools, we need to look at some basic concepts of debugging. Bugs A bug is anything that doesn't work exactly as expected. Bugs can be fatal - they can crash your machine - or bugs