ARM > Efficient C for ARM > Padding
Example
Consider the structure:
struct
{
unsigned char type;
int product;
short delta;
}
It is laid out in memory like this:
But if we sort the structure members by size, largest to smallest:
struct
{
int product;
short delta;
unsigned char type;
}
The padding can be removed and the structure reduces by four bytes (a third).