/* dangerous due to misalignment problems */ B = (double **) malloc(m*sizeof(double *)+m*n*sizeof(double)); if ( B == NULL ) return NULL; B[0] = (double *)(B[m]); /* now set the other pointers */ for ( i = 1; i < m; i++ ) B[i] = B[0] + i*n;