2 ms·
> but I don’t understand why these extra paddings are present and why one is gone In the example from the article, the "s_arc" member is a pointer (8 bytes) an
by bluetomcat 2y ago
> but I don’t understand why these extra paddings are present and why one is gone
In the example from the article, the "s_arc" member is a pointer (8 bytes) and requires an alignment at an 8-byte boundary. The ints are 4 bytes in size. The whole struct needs to be aligned on an 8-byte boundary, in order to preserve the alignment requirements of the pointers. The trailing "s_accept" member requires additional padding to make the size of the struct divisible by 8, and that would preserve the alignment of an eventual second adjacent struct, when having an array of these structs.