Huw Davies huw@codeweavers.com wrote:
typedef struct {
- WORD PosFormat;
- WORD Coverage;
- WORD ValueFormat1;
- WORD ValueFormat2;
- WORD ClassDef1;
- WORD ClassDef2;
- WORD Class1Count;
- WORD Class2Count;
- WORD Class1Record[1];
+} GPOS_PairPosFormat2;
Shouldn't this structure be 2 bytes aligned?
On Thu, Dec 20, 2012 at 10:12:38PM +0800, Dmitry Timoshkov wrote:
Huw Davies huw@codeweavers.com wrote:
typedef struct {
- WORD PosFormat;
- WORD Coverage;
- WORD ValueFormat1;
- WORD ValueFormat2;
- WORD ClassDef1;
- WORD ClassDef2;
- WORD Class1Count;
- WORD Class2Count;
- WORD Class1Record[1];
+} GPOS_PairPosFormat2;
Shouldn't this structure be 2 bytes aligned?
I don't see why. They're all WORDs.
Huw.
Huw Davies huw@codeweavers.com wrote:
typedef struct {
- WORD PosFormat;
- WORD Coverage;
- WORD ValueFormat1;
- WORD ValueFormat2;
- WORD ClassDef1;
- WORD ClassDef2;
- WORD Class1Count;
- WORD Class2Count;
- WORD Class1Record[1];
+} GPOS_PairPosFormat2;
Shouldn't this structure be 2 bytes aligned?
I don't see why. They're all WORDs.
There are 9 elements of 2 bytes in size each, 18 bytes in total, the compiler will align this structure to 4 bytes, making its size 20 bytes.
On Thu, Dec 20, 2012 at 11:05:48PM +0800, Dmitry Timoshkov wrote:
Huw Davies huw@codeweavers.com wrote:
typedef struct {
- WORD PosFormat;
- WORD Coverage;
- WORD ValueFormat1;
- WORD ValueFormat2;
- WORD ClassDef1;
- WORD ClassDef2;
- WORD Class1Count;
- WORD Class2Count;
- WORD Class1Record[1];
+} GPOS_PairPosFormat2;
Shouldn't this structure be 2 bytes aligned?
I don't see why. They're all WORDs.
There are 9 elements of 2 bytes in size each, 18 bytes in total, the compiler will align this structure to 4 bytes, making its size 20 bytes.
The size is irrelevant - it's variable sized anyway. We just care about the offsets of the elements.
Huw Davies huw@codeweavers.com wrote:
There are 9 elements of 2 bytes in size each, 18 bytes in total, the compiler will align this structure to 4 bytes, making its size 20 bytes.
The size is irrelevant - it's variable sized anyway. We just care about the offsets of the elements.
Anyway, in order to avoid any confusion or bugs in future with allocating an array of such structures or using sizeof() on them I'd suggest to explicitely specify alignment.
On Thu, Dec 20, 2012 at 11:26:36PM +0800, Dmitry Timoshkov wrote:
Huw Davies huw@codeweavers.com wrote:
The size is irrelevant - it's variable sized anyway. We just care about the offsets of the elements.
Anyway, in order to avoid any confusion or bugs in future with allocating an array of such structures or using sizeof() on them I'd suggest to explicitely specify alignment.
Using an array of these structures or using sizeof() is wrong anyway as they are variable-sized...
Dmitry Timoshkov dmitry@baikal.ru writes:
There are 9 elements of 2 bytes in size each, 18 bytes in total, the compiler will align this structure to 4 bytes, making its size 20 bytes.
No it won't.