News for hackers. Stuff that matters.
Re:Ask HN: Favorite pointer tricks in C? by jhrobert on Saturday November 20, 2010 @05:04PM (#1925459)
implementing linked lists the way the linux kernel does, that is: each node contains one pointer for each list it can be part of, that pointer's position is determined using some offset_of( field, name) macro.
Re:Ask HN: Favorite pointer tricks in C? by jallmann on Saturday November 20, 2010 @05:15PM (#1925500)
I've recently started using offsetof in my own code, it's a pretty neat operator. Useful for nested structs, where you have a child but need to reference the parent.