[Xcb] [PATCH proto 1/2] Add sizeof tag to struct
Daniel Martin
consume.noise at gmail.com
Thu Jan 3 05:53:12 PST 2013
On Thu, Jan 03, 2013 at 12:46:06PM +1000, Peter Hutterer wrote:
> On Sun, Dec 23, 2012 at 03:29:23PM +0100, Daniel Martin wrote:
> > If a struct provides all necessary informations to calculate it's
> > size, i.e. an explicit length field, this sizeof tag makes it possible
> > to reference to the length field with an expression (known from lists).
> > This makes further iterations over these structs very easy, as we don't
> > have to sum up all field lengths, lists and may add padding.
> >
> > structs with such a length field can be found in the XInput extension.
> > For example the device classes (xXIButtonInfo, xXIKeyInfo, ...):
> > http://cgit.freedesktop.org/xorg/proto/inputproto/tree/XI2proto.h#n136
> >
> > Signed-off-by: Daniel Martin <consume.noise at gmail.com>
>
> I don't know enough about xcb's internals but the approach seems sensible.
> two typos pointed out below.
...
> > + If the optional sizeof element is present it provides a simple way to
> > + compute the struct size at runtime. This is usefull if the struct itself
>
> useful
>
> > + contains a length field referencing the whole struct. With that given it's
> > + not necessary to sum up all fields, lists and pads of the struct.
> > + DO NOT use it the work around alignmend issues. Use the packed attribute
>
> alignment
Thanks, changes applied.
More information about the Xcb
mailing list