Hey All,
I've got a problem with some C we are working on (embedded systems), right now we have a huge 2D array that works fine, it looks like this
I need to convert that to use our lightweight memory allocator, (effectively just malloc with some RTOS specific stuff added in)
C pointers always hurt my head but I can't figure this one out, I effectively need to say
But then I have no idea how to have code index into the array properly. Is it possible at that point to still index items directly (Array[x][y]) or will array operations have to go through a reader/writer function that needs to be built?
Many Thanks!
For those who want more info, it's a embedded system with 64K of RAM, and this array is about 10K that gets statically assigned by the linker, we need to move it to the lightweight allocator which will allow that RAM space to be used for something else when the task that is using this memory is shut down.
I've got a problem with some C we are working on (embedded systems), right now we have a huge 2D array that works fine, it looks like this
Code:
t_ourStructType Array[SIZE1][SIZE2];
I need to convert that to use our lightweight memory allocator, (effectively just malloc with some RTOS specific stuff added in)
C pointers always hurt my head but I can't figure this one out, I effectively need to say
Code:
t_ourStructType *Array;
Array = _mem_alloc(sizeof(ourStructType * SIZE1 * SIZE2));
But then I have no idea how to have code index into the array properly. Is it possible at that point to still index items directly (Array[x][y]) or will array operations have to go through a reader/writer function that needs to be built?
Many Thanks!
For those who want more info, it's a embedded system with 64K of RAM, and this array is about 10K that gets statically assigned by the linker, we need to move it to the lightweight allocator which will allow that RAM space to be used for something else when the task that is using this memory is shut down.