Recently we updated our site’s framework to use WordPress. This should allow easier content management, as well as several new features. Article comments are now enabled, as well as in-site search and new member registration.
Hope you enjoy the changes,
CodeMaestro team
Standard preprocessor checks can be very useful to catch programming errors. Nevertheless, these checks can be very limited, as they can only evaluate preprocessor expressions, rather than compile time values like sizeof. Presented here is a small piece of code to create compile time checks
Very few programming languages allow the user to define functions with variable number of parameters. Although this method is very powerful, it should be used carefully. In this article we will explore variadic functions and macros, as well as ways to better utilize this capability.
Linux, like most POSIX / System V compatible operating systems prefer processes over threads, as a matter of fact, a POSIX thread is nothing but a process with a layer of abstraction.
Optimizing Singletons With Double Checks
Writing a thread safe singleton has its difficulties. One of them is making sure that the dynamic creation of the inner singleton object is thread safe, while locking as few mutexes as possible.
Magical Square Root Implementation In Quake III
Any 3D engine draws it’s power and speed from the mathematical models and implementations within, and trust John Carmack of ID software for using really good hacks. As it turns out, a very interesting hack is used in Quake III to calculate an inverse square root.
Fast Atomic Counters With the x86 LOCK Prefix
Atomic counters are the foundation of any thread safe reference counter. They are also common in daily use for thread counting and many other uses. Regularly, implementing thread safe atomic counters can be done in several ways, but always with a performance cost. In this review we will examine a method to implement a reference counter with a single assembly instruction.
Controlling the Packing Alignment to Minimize Memory Consumption in C/C++
Do you know how much memory your structs and classes require? Unless you plan carefully, structs and classes may require as much as twice memory than actually needed, due to the compiler’s default packing alignment. The pack directive can be used in order to define the best packing alignment for your code.
Loop Unrolling with Duff’s Device
Loop unrolling, or unwinding, is simply reducing the number of overhead instructions that the CPU has to execute in a loop, thus improving the cache hit rate and the loop’s run time.
Some programs rely on specific CPU instructions, with features like MMX, 3DNow!, Hyper Threading, etc. Some of them even rely on the specific CPU version. How would they know for sure that the CPU has what it takes to operate?
Easy tricks for optimizing common string operations
Whether your data structure uses hashes, trees or any other pattern to store strings, it all boils down to comparing your query string against strings from the repository. The actual string comparison is an aspect sometimes overlooked. This article lists some easy tricks that could make your string comparisons run much faster.
Easy DWORD-Alignment of Binary Structures
Information stored in binary data structures is an area so fundamental that there is hardly any field in the industry that doesn’t relate to the parsing or extracting of binary memory sources. However, my intention in this article are so small and specific, that I really want to believe there’s someone else out there […]
Implementing a Message Dispatcher in Multi-Core Environments
Multi core programming presents different challenges than traditional parallel computing. In this article we will explore a programming paradigm called ‘the dispatcher’ and its implementation in multi-core environment.
Implementing Callback Functions Using Delegates in C++
Nice C++ object oriented code basically means writing everything in objects/classes. However, not everything we need in programming is classes. This article concentrates on callback functions, and presents a C++ implementation of delegates which doesn’t use pointers to functions.
This item is a must for every Visual C++ 6.0 programmer which uses operator new. The default behavior of operator new in Microsoft Visual C++ 6.0 in case of an error is to return NULL, in total contrast to the standard which explicitly states that new raises a bad_alloc exception upon failure. This behavior can lead to many unpleasant surprises, especially when trying to write portable code.
Asynchronous Message Handling in MFC
This article presents a possible solution to an inherited problem in the MFC programming environment. According to the MFC architecture, all messages are handled synchronously. Of course, this issue makes no difference in the case that for every single message you want to process, the processing will take you only a short time.
Delay Load Dlls Error Recovery - Putting the ‘D’ back in the Dll
This article suggests that dynamic loading errors can be solved quite easily by using the delay load Dlls mechanism wisely, and demonstrates a way to transform any code that uses Dll’s to be error free using the delay load mechanism, while keeping it’s elegance.
Powered by WordPress