[vlc-devel] [PATCH] objects: get the vlc_object_t from vlc_object_internals using vlc_internals()

Steve Lhomme robux4 at gmail.com
Wed Jul 26 08:29:35 CEST 2017


On Tue, Jul 25, 2017 at 9:25 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> Le tiistaina 25. heinäkuuta 2017, 20.58.44 EEST Steve Lhomme a écrit :
>> Can you point to doc about that because I couldn't understand how it works
>> in the regular case (and it does). Because my understanding of container_of
>> is that it gives the starting offset of the field in the structure. Except
>> in this case it's the end of the structure.
>
> Uh? container_of(p,t,m) returns a pointer to a structure of type 't' that
> contains a member 'm', to which 'p' points.

Yes I meant offsetof().

With gcc offsetof(struct vlc_object_internals, aligned_end) gives 160.
Which is also sizeof(struct vlc_object_internals). Which seems very
odd to me. It's as if aligned_end had no size at all.

And on my other compiler offsetof() 152 when the sizeof() is 160. And
because of the the vlc_internals/externals is broken. They don't point
to the same area.

That's I think
1/ having a static assert to make sure what is expected is there
2/ accessing the pointers in a consistent way is better

> See MMDevice callbacks for a good example.
>
> --
> 雷米‧德尼-库尔蒙
> https://www.remlab.net/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list