M
mojumbo
Problem:
I have a structure which needs to store its data in contiguous memory
by there is a dynamic element which can't be defined at compile time.
It needs to be aligned along a 4 byte boundary. This is what my
structure looks like:
START
struct tsBob
{
unsigned int fieldA;
unsigned int fieldB;
unsigned short varLen[0];
}
tsBob* myBob;
myBob = (tsBob*)malloc(sizeof(tsBob) + sizeof(unsigned short) * 1);
END
myBob needs an additional 3 bytes alloc'd to it to be aligned. I
don't want to use %
Finally the question,
Can I use a bitwise something to determine how many extra bytes I need
and malloc that with the
rest of the function call?
I have a structure which needs to store its data in contiguous memory
by there is a dynamic element which can't be defined at compile time.
It needs to be aligned along a 4 byte boundary. This is what my
structure looks like:
START
struct tsBob
{
unsigned int fieldA;
unsigned int fieldB;
unsigned short varLen[0];
}
tsBob* myBob;
myBob = (tsBob*)malloc(sizeof(tsBob) + sizeof(unsigned short) * 1);
END
myBob needs an additional 3 bytes alloc'd to it to be aligned. I
don't want to use %
Finally the question,
Can I use a bitwise something to determine how many extra bytes I need
and malloc that with the
rest of the function call?