S
Spoon
Hello everyone,
As far as I understand, if I request a uint8_t buffer,
it could be allocated anywhere.
uint8_t *buf = new uint8_t[1328]
By anywhere, I mean e.g. it could start at an odd address.
Therefore it might be incorrect to access 32 bits at a time:
*(uint32_t *)(buf+4*i) is probably illegal.
If I want a uint8_t buffer that is aligned on, say, 32 bits,
can I do the following:
uint8_t *buf = ( uint8_t * )( new uint32_t[1328/4] );
and have the guarantee that I can always access
*(uint32_t *)(buf+4*i) without any problem?
What if I want to align to 256 bits?
Do I have to create a bogus 256-bit structure?
(Since there is no native 256-bit integral type.)
Regards.
As far as I understand, if I request a uint8_t buffer,
it could be allocated anywhere.
uint8_t *buf = new uint8_t[1328]
By anywhere, I mean e.g. it could start at an odd address.
Therefore it might be incorrect to access 32 bits at a time:
*(uint32_t *)(buf+4*i) is probably illegal.
If I want a uint8_t buffer that is aligned on, say, 32 bits,
can I do the following:
uint8_t *buf = ( uint8_t * )( new uint32_t[1328/4] );
and have the guarantee that I can always access
*(uint32_t *)(buf+4*i) without any problem?
What if I want to align to 256 bits?
Do I have to create a bogus 256-bit structure?
(Since there is no native 256-bit integral type.)
Regards.