News for hackers. Stuff that matters.
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.

Re:Dirty Coding Tricks by United857 on Thursday January 08, 2015 @04:55PM (#8859273)
Interesting enough, the current 64-bit ObjC runtime does something similar, with so-called "tagged pointers".

https://www.mikeash.com/pyblog/friday-qa-2013-09-27-arm64-an...

Re:Dirty Coding Tricks by jheriko on Wednesday January 14, 2015 @11:55AM (#8887421)
right, but then why can't you take that same opportunity to pull your pointer out and replace it with a zero to avoid it being free'd ?