Just get the caller to provide the buffer and if need be the size of buffer. I am after any allocation that wont be on a 16bit aligned address on a PIC24F because those are the ones that will gotcha me on my coding.Īs ric said that is not a great idea you are asking to bleed memory because there is no obvious owner to be given the task of cleanup. 2.) Local variable void func (void) uint8_t a // this should be 2 byte aligned uint8_t b // this should be two byte aligned the stack will pad the extra byte 3.) Global variable uint8_t a // this should be 2 byte aligned uint8_t b // this should be two byte aligned the data will have a hole with the extra byte So this comes back to the crux of my question how do you create a non aligned array of uint8_t, uint16_t or anything? I am excluding some dodgy pointer operation setting an odd address, you can do that on any CPU. I can't imagine they would be silly enough to not 2 byte align the heap. I am assuming that anything it gives you back will be 2 byte boundary. So lets cover the three situations and confirm I am expecting 1.) Malloc. ![]() On an ARM you would have to go out of your way to get a byte aligned array it is dam difficult and I have coded that way on the PIC24F without issue, so was shocked at your response. I assumed like most ARM riscs that all natural allocations will be on 2 byte boundaries to match the 16bit processor because usually riscs hate manhandling byte alignments. ![]() I only started on the PIC 16 bit processors for 1 little job after years on 32 micros so bear with me here because I haven't had an issue up todate and what you said stuns me.
0 Comments
Leave a Reply. |