我正在尝试使用 Cudd 包在 Visual C 中实现一个算法。我必须递归地使用一个函数。但它不断在某一行抛出错误。错误是访问冲突读取位置 0x00594a5ct。它与temp_bdd_result的使用背道而驰。我无法弄清楚为什么会发生这种情况,因为 temp_bdd_result-bdd_node 和 bdd_result 中使用的两个值都包含值。那么为什么它们无法访问。或者这个错误指向我看不到的其他东西。请帮忙。
DdNode* Path_Function_Construct(DdManager *manager,int matrix[3][3],int source)
{
DdNode *bdd_node,*bdd_result,*e,*temp_bdd_node,*temp_bdd_result;
if (source>=rows)
return Cudd_ReadOne(manager);
else
{
bdd_result=Cudd_ReadZero(manager);
Cudd_Ref(bdd_result);
for (int j=0;j<columns;j++)
{
if (matrix[source][j]==1)
{
//Declaring temp variables
//This means that an edge exists between source and node in consideration
e=Cudd_bddNewVar(manager);
Cudd_Ref(e);
//Removing redundant nodes
int new_matrix[3][3];
for(int l=0;l<rows;l++)
for(int m=0;m<columns;m++)
new_matrix[l][m]=matrix[l][m];
for(int i=0;i<rows;i++)
new_matrix[i][j]=0;
//find path function using that node as a source
temp_bdd_node=Path_Function_Construct(manager,new_matrix,j+1);
Cudd_Ref(temp_bdd_node);
bdd_node=Cudd_bddAnd(manager,e,temp_bdd_node);
Cudd_Ref(bdd_node);
temp_bdd_result=Cudd_bddIthVar(manager,4);
temp_bdd_result=Cudd_bddAnd(manager,bdd_result,bdd_node); //this is where error is coming
Cudd_Ref(temp_bdd_result);
Cudd_RecursiveDeref(manager,bdd_result);
bdd_result=temp_bdd_result;
Cudd_Ref(bdd_result);
Cudd_RecursiveDeref(manager,temp_bdd_node);
Cudd_RecursiveDeref(manager,temp_bdd_result);
Cudd_RecursiveDeref(manager,bdd_node);
Cudd_RecursiveDeref(manager,e);
} // end of if (matrix[source][j]==1)
}// end of for loop
return (bdd_result);
}
}