I'm trying to understand a piece of C code which is as follows:
#define DIM2( basetype, name, w1 ) basetype (*name)[w1]
int mx = 10; //number of rows per processor
int my = 100; //number of cols
DIM2 (double, f, my);
f = (typeof (f)) malloc (2 * mx * sizeof (*f));
If I'm correct, with DIM2 a 1-d array of (size=100) pointers to double is created. I'm not able to understand what happens again with malloc? Is it necessary for two such statements?
Is there any alternative way to achieve what happens in the last two lines of code above in any other way?