News for hackers. Stuff that matters.
Re:Ask HN: Favorite pointer tricks in C? by xtacy on Saturday November 20, 2010 @05:34PM (#1925558)
I like the trick of using the last few bits of aligned pointers to store something useful. It's tricky and has to be done correctly. A class wrapper around the pointer would be better.

For e.g., a constraint in an AVL tree requires that the difference in sizes of left and right subtrees be -1, 0 or 1 (just 3 values, which requires 2 bits). A 4-byte aligned pointer would be enough. =)

Re:Ask HN: Favorite pointer tricks in C? by bnastic on Monday November 22, 2010 @08:16AM (#1929649)
This trick has been around for a very long time. I remember Tempus Editor on Atari ST (remember those?) using 8 bits of address registers for additional storage (as only 24 bits out of 32 were used for addressing).
Re:Ask HN: Favorite pointer tricks in C? by mansr on Sunday November 21, 2010 @07:28AM (#1926962)
This trick is often seen in language interpreters. Two widely used examples are Emacs Lisp and Mozilla Spidermonkey Javascript.
Re:Ask HN: Favorite pointer tricks in C? by benreesman on Sunday November 21, 2010 @01:44AM (#1926538)
this is how v8 does tagged pointers.