I've been thinking abit on howto implement multidimensional arrays and i found that its quite tricky :). I'm currently thinking of having a structure that contains a data pointer and its location in every dimension something like this: typedef struct CELL { int dim[100]; int *data; } cell;
cell *a = (cell *)malloc((unsigned) (2)*sizeof(cell *)); // A cell with location in a 3 dim space a(2;4;6) a->dim[0] = 2; a->dim[1] = 4; a->dim[2] = 6; a->data = data1; This way it dosent matter how the structure is in the memory we could actually do some coloring "similar to linux kernels page coloring" to optimise memory alignement. One major things is howto access the data..Heh I've been thinking of having a key to find the correct element in memory. eg addr_of_cell = baseaddr_of_malloced_data * (some wonderfull magic) I dont know if its doable but at a glanse i think it could work. We could maybe even change "( some wonderfull magic )" part in runtime to rearange the data. Maybe im really wrong in my thinking if so maybe this mail leads to better solution. /josef