cpp

Using Gflags Page Heap to Debug on Windows

TL;DR - It sets a global flag so that when the OS allocates memory in your application, it specifically sticks the allocated chunk at the end of the page, with a special no access page after each used page. Then any buffer overrun becomes immediately obvious! What happened We have a relatively simple standalone Windows MFC desktop app (old school) whose sole purpose is to take user inputs and call into a third party library with them.
Read more

Smart Pointer Pointers

TL;DR - Switch raw heap pointers to unique_ptrs when possible. If your heap allocated resource needs multiple owners, use a shared_ptr instead. I find myself reviewing C++ smart pointer types over and over again. I guess for me, it’s just been one of those things that doesn’t stick, or perhaps I’ve only needed to use them infrequently enough to forget about them. So, here’s a note to myself, and anyone else dying to read about smart pointers in C++.
Read more