void resizecmat(CMat* A, int r, int c)
{
	if (A == NULL) return;
	if ((A->row == r) && (A->col == c))
		return;

	for (int ri = 0; ri < A->row; ri++)
		tfree(A->d[ri]);

	if (A->d != NULL)
		tfree(A->d);

	A->row = r; A->col = c;
	A->d = (cplx**)tmalloc(sizeof(cplx*) * (size_t)r);

	if (A->d == NULL) return;

	for (int i = 0; i < r; i++)
		A->d[i] = (cplx*)tmalloc(sizeof(cplx) * (size_t)c);
}

Please add comments to this code. Then Explain what the code is doing