malloc函数声明一个二维动态数组A,使用omp并行对A赋值,然后释放A内存时报错。在不使用并行时,不会报错。谢谢!代码如下:
void main(){
void main(){
int i,j, Njuncs=1827;
//创建二维数组A
double**A = (double **)malloc(sizeof(double *)*(Njuncs + 1));
for (i = 0; i < Njuncs + 1; i++)
*(A + i) = (double *)malloc(sizeof(double) * (Njuncs + 1));
#pragma omp parallel
{
#pragma omp for
for (i = 0; i <= Njuncs; i++)
for (j = 0; j <= Njuncs; j++)
A[i][j] = 1;
}
for (i = 0; i < Njuncs + 1; i++){
free(*(A + i));//该步报错
A[i] = NULL;
}
free(A);
}