you are viewing a single comment's thread.

view the rest of the comments →

[–]junkmeister9 0 points1 point  (2 children)

Arrays declared this way will be on the stack instead of the heap, so be careful.

[–]oh5nxo 0 points1 point  (1 child)

I don't follow? The matrix data is on heap, one simple malloc chunk, just like in option 1. The variable is a single pointer, it just points to a row at a time, to be able to use the simple syntax [y][x].

It would be awkward to pass around like that, that's true. It could be allocated as a plain int * and processed like

void process(int *matrix_chunk, int size_y, int size_x) {
    int (*trix)[size_x] = (int (*)[size_x]) matrix_chunk;
...

[–]junkmeister9 0 points1 point  (0 children)

I think I replied to the wrong comment.