On Thu, Feb 10, 2011 at 3:54 PM, Alon Levy <al...@redhat.com> wrote: > I prefer CONTAINEROF. It's properly intimidating, and it checks that > the cast-to struct has a field of the correct type, so it is much > safer then just (X*). There is an UPCAST macro in use by qemu and kernel > too I think that is basically the same as CONTAINEROF with the addition > of enforcing an offset 0 of the base type, in effect the same as what > you think as an upcast. We should probably add that and use it.
+1, that's exactly what I would use + some of kind of "optional" light type checking if possible (iirc, PulseAudio has one) > are later places where I have > struct ChannelClient { > RingItem client_link; > RingItem channel_link; > } > > So I actually need sometimes to do a CONTAINEROF with non zero offset (can't > make both client_link and channel_link first in the list..) oh sure, I was talking about class casting cases only. regards -- Marc-André Lureau _______________________________________________ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel