/*----------------------------
* 功能 二维指针动态分配内存
*----------------------------*/
void malloc2D(double **&a, const int rows, const int cols)
{
const int Rows = rows;
const int Cols = cols;
a = new double*[Rows];
for (int i = 0; i < Rows; i++)
a[i] = new double[Cols];
assert(a != NULL);
}
/*----------------------------
* 功能 对二维指针动态分配的内存释放
*----------------------------*/
void free2D(double **&a, const int rows, const int cols)
{
const int Rows = rows;
const int Cols = cols;
for (int i = 0; i < Rows; i++)
free(a[i]);
}
//创建
int iRows = iCols = 10;
double **depth_M = NULL; //存储深度图数据,用于聚类
malloc2D(depth_M, iRows, iCols);
free2D(depth_M, iRows, iCols);