Dict parsing question

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Tue Jan 2 21:28:03 UTC 2024


On Tue, 2 Jan 2024 11:47:30 +0000, Simon McVittie wrote:

> This is not just dicts: the elements of an array of (u)int64 or double
> have the same property that the 8-byte alignment of each element is
> greater than the 4-byte alignment of the first byte of the array
> length. This just means that you might need padding between the
> array length and the actual content (the first element).

But you don’t know on what boundary the array length is positioned: if
it’s already at an address that is a multiple of 8 bytes (which could
happen, say, 50% of the time), then the addition of 4 bytes of padding
means the element field is no longer 8-byte-aligned.

This is why, in order to have 8-byte alignment for the elements of a
structure, you have to guarantee at least 8-byte alignment for the
structure itself.


More information about the dbus mailing list