> 
> > > I don't find this very readable, and imo there is not a huge gain in
> > > doing this over a cast... I'd just go with a cast + a static
> > > compile-time assert that RedCursorPipeItem has a 'base' RedPipeItem
> > > field at offset 0.
> > > 
> > 
> > static void cursor_pipe_item_free(RedPipeItem *base)
> > {
> >    spice_return_if_fail(base);
> > 
> >    verify(SPICE_OFFSETOF(RedCursorPipeItem, base) == 0);
> >    RedCursorPipeItem *pipe_item = (RedCursorPipeItem *) base;
> >    ...
> > 
> > (obviously for every cast)
> 
> I'd put it next to the structure definition and forget about it
> 
> typedef struct RedCursorPipeItem {
>     RedPipeItem base;
>     CursorItem *cursor_item;
> } RedCursorPipeItem;
> 
> verify(SPICE_OFFSETOF(RedCursorPipeItem, base) == 0);
> 
> Christophe
> 

You didn't understand the problem, this is not enough
as a refactory of this would require a complete code scan
as currently is (was?) needed, you have to check for every
cast.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to