This is how I allocate space for a matrix

how can I deallocate the same matrix?Code://Initialize matrix *matrix= (float**) malloc(Rows * sizeof(float *)); for (i=0;i<Rows;i++){ (*matrix)[i]=(float *) malloc(MCols * sizeof(float)); for (j=0 ;j<MCols;j++){ (*matrix)[i][j]=0.0; } }

I used this code:

(is it correct??)Code:void deallocateMatrix(float ***matrix, int numRows){ int i; for(i=0;i<numRows;i++){ free((*matrix)[i]); } free(*matrix); }

but it doesn't works. And nothing again with **matrix in input.