Re:Dirty Coding Tricks
by cbhl on Thursday January 08, 2015 @04:43PM
(#8859215)
You'd probably only need two or three bits to pack a controller id. Depending on how much memory the system has, and and things like data alignment, you can find some bits in the pointer that will always have a specific value (say, zero). Then, you can store the ID in those bits, and mask them away when you actually want the pointer.
Edit: You probably shouldn't do this in new code, but in the context of memory-constrained C code it's a nice hack.
Edit: You probably shouldn't do this in new code, but in the context of memory-constrained C code it's a nice hack.