C: Possible glitch in my memory deallocation function
===

I'm developing a small C library with functions for frequently used operations, mainly to rub up my C skills. In a session of debugging my deallocation function, i saw that the value of a pointer which previously pointed at a two-dimensional matrix isn't **NULL**. 

I know that there is not a way to check the state of a pointer after deallocation (from [reading][1] this question), but i assigned a **NULL** value to this pointer to avoid it to eventually become a dangling pointer.

Function code is:

    void matfree(void **M, int m){
	int i;

	for(i = 0; i < m; i ++){
		free(M[i]);
		M[i] = NULL;
	}
	free(M);
	M = NULL;
    }

Test code (into another file):

    int matfreetest(){
	int **M = NULL;

	M = (int **) matmalloc(0, 2, 2);
	if(*M == NULL){
		printf("Here 1! \n");
		return 0;
	}
	matfree(M, 2);
	if(*M == NULL){
		return 1;
	}
	else{
		printf("Here 2! \n");
		return 0;
	}
    }

    int main(){
	int status; 

	status = matmalloctest();
	printf("matmalloctest status = %d \n", status);
	status = matfreetest();
	printf("matfreetest status = %d \n", status);
	system("PAUSE");
	return 1;
    }

I expected matfreetest to return status 1, but it returns 0. What is done wrong here?
  [1]: http://stackoverflow.com/questions/4143382/how-to-check-deallocation-of-memory