<div dir="ltr"><div>Thank you,<br><br></div>m.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-05-23 21:03 GMT+02:00 Simon McVittie <span dir="ltr"><<a href="mailto:simon.mcvittie@collabora.co.uk" target="_blank">simon.mcvittie@collabora.co.uk</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 23/05/16 19:46, <a href="mailto:marcin@saepia.net">marcin@saepia.net</a> wrote:<br>
> the array length is not aligned to 8 bytes, but to 4 bytes. But type of<br>
> this array is struct, which according to the specification should always<br>
> align to 8 bytes.<br>
<br>
</span>The header field array isn't a struct, it's an array (which happens to<br>
contain structs). The array length is a 4-byte integer, so it's aligned<br>
to a multiple of 4 bytes. After the length, there are some number of<br>
structs, and *those* are aligned to a multiple of 8 bytes.<br>
<br>
In effect, the beginning of every message looks like this:<br>
<br>
bytes 0-3: header start, four 1-byte quantities<br>
4-7: body length<br>
8-11: serial<br>
No padding, 12 is already a multiple of 4<br>
12-15: header field array length<br>
No padding, 16 is already a multiple of 8<br>
16+: first header field struct<br>
<br>
Let's say the first header field struct happens to be 13 bytes long.<br>
We'd continue as follows:<br>
<br>
16-28: first header field struct<br>
29-31: 3 bytes of padding to reach next multiple of 8<br>
32+: second header field struct<br>
<br>
(Yes, this means the marshalling for `a(whatever)`, an array of structs,<br>
is not the same as the marshalling for `(a(whatever))`, a struct<br>
containing a single array of structs. There's no particular reason, it's<br>
just how this stuff was designed 10+ years ago.)<br>
<br>
Regards,<br>
S<br>
<span class="HOEnZb"><font color="#888888">--<br>
Simon McVittie<br>
Collabora Ltd. <<a href="http://www.collabora.com/" rel="noreferrer" target="_blank">http://www.collabora.com/</a>><br>
<br>
_______________________________________________<br>
dbus mailing list<br>
<a href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/dbus" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dbus</a><br>
</font></span></blockquote></div><br></div>