Thanks Elysia,
The way I'm allocating 2d arrays is this:
Code:
arr2d=malloc(rows*sizeof(*arr2d));
if (arr2d==NULL) {
printf("Could not allocate data array of size %i\n",rows*sizeof(*arr2d));
return NULL;
}
for (i=0; i<rows; i++) {
arr2d[i]=malloc(cols*sizeof(*arr2d[i]));
if (arr2d[i]==NULL) {
printf("Could not allocate array data[%i] of size %i\n",i, cols*sizeof(*arr2d[i]));
return NULL;
}
}
So if I've understood right then passing a pointer to pointer is the appropriate way. Am I right?
Would you then say that there's nothing wrong with