B
barcaroller
I have a multi-field struct and a memory block (created using malloc) that
contains structured data. If I map the struct to the memory block, am I
guaranteed that the struct fields will be filled properly or do I have to
worry about the compiler padding the struct?
Example:
typedef struct
{
int16 field1; // 2 bytes
int32 field2; // 4 bytes
} st;
// memblock contains exactly 6 bytes
st* var = (st*) memblock;
contains structured data. If I map the struct to the memory block, am I
guaranteed that the struct fields will be filled properly or do I have to
worry about the compiler padding the struct?
Example:
typedef struct
{
int16 field1; // 2 bytes
int32 field2; // 4 bytes
} st;
// memblock contains exactly 6 bytes
st* var = (st*) memblock;