[vlc-devel] [PATCH] objects: get the vlc_object_t from vlc_object_internals using vlc_internals()
robux4 at gmail.com
Tue Jul 25 20:58:44 CEST 2017
Le 25 juil. 2017 19:45, "Rémi Denis-Courmont" <remi at remlab.net> a écrit :
Le tiistaina 25. heinäkuuta 2017, 19.22.19 EEST Steve Lhomme a écrit :
> On Tue, Jul 25, 2017 at 6:33 PM, Rémi Denis-Courmont <remi at remlab.net>
> > Le tiistaina 25. heinäkuuta 2017, 18.06.32 EEST Steve Lhomme a écrit :
> >> So that's it coherent with the rest of the usages.
> > Not really. The other uses operate on an initialized object. Here, we
> > creating and initializing the object.
> It's just about accessing the pointer.
Says who? I wrote those accessor macros, and that´s not how I conceived them
nor how I think of them. Using accessors on unitialized objects makes no
Insisting on having distinct ways to access the same thing is what doesn't
make sense to me. But if you do insist then add a static assert to ensure
when you compile that your advanced pointer tricks actually match in both
> It doesn't matter what is in the pointed data.
The current implementation of the macros is such that initialization does
matter. Likewise, it is such that this patch does not matter; it replaces
expression with an equivalent expression.
> > flexible array in ISO C ensures that the two expressions are equivalent.
> > One uses byte offsets, and the other direct pointer arithmetic.
> If that was equivalent, this wouldn't fail:
> static_assert( sizeof(struct vlc_object_internals) !=
> offsetof(struct vlc_object_internals, aligned_end),
> "invalid align_end access");
It *is* equivalent, and that assertion *cannot* fail.
By definition of pointer arithmetic, pointer plus one equals the pointer
the size of pointed type and by definition of flexible arrays, the offset
flexible array within its contained structure is the size of the structure.
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.
That was the whole point of appending aligned_end in the first place.
vlc-devel mailing list
To unsubscribe or modify your subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vlc-devel