Archive for the tag: C

Flattening Multidimensional Arrays

Tags:, 2 Comments »
Edit: Thank you, fixitman for the insightful comment; the code has been fixed to work with non-square arrays as well.

In an effort to produce a better performing multidimensional array, I would like to share the following with you. Say we have a Matrix (or multidimensional array) of 5 x 5 integer elements, M. In order to allocate such an array in C++, we use the following code:
Read the rest of this entry »

CriticalSection wrapper class

Tags:, , , , 2 Comments »

What: A C++ wrapper around both WINAPI (Microsoft Windows) and PThreads (POSIX threads) functionality.
Why: To abstract cross platform functionality.
Remarks: On windows, CRITICAL_SECTION objects cannot be shared cross-process. This means that the class is tied to your application or DLL process. Comments are in Doxygen/Javadoc style.
Read the rest of this entry »

Bitwise Operators Article

Tags: No Comments »

I thought it might be a good idea to include an article on bitwise operators in C since many Graphics APIs use bitwise operators for flags, etc. So I did, although it requires some additional content expansion. Check it out here.