@@ -116,11 +116,10 @@ int Aig_ObjRequiredLevel( Aig_Man_t * p, Aig_Obj_t * pObj )
116116***********************************************************************/
117117int Aig_ObjReverseLevelNew ( Aig_Man_t * p , Aig_Obj_t * pObj )
118118{
119- Aig_Obj_t * pFanout ;
120- int i , iFanout = -1 , LevelCur , Level = 0 ;
121- Aig_ObjForEachFanout ( p , pObj , pFanout , iFanout , i )
119+ int i , iFanout = -1 , FanoutId , LevelCur , Level = 0 ;
120+ Aig_ObjForEachFanoutId ( p , pObj , FanoutId , iFanout , i )
122121 {
123- LevelCur = Aig_ObjReverseLevel ( p , pFanout );
122+ LevelCur = Vec_IntGetEntry ( p -> vLevelR , FanoutId );
124123 Level = Abc_MaxInt ( Level , LevelCur );
125124 }
126125 return Level + 1 ;
@@ -250,6 +249,8 @@ void Aig_ManUpdateReverseLevel( Aig_Man_t * p, Aig_Obj_t * pObjNew )
250249 int LevelOld , LevFanin , Lev , k ;
251250 assert ( p -> vLevelR != NULL );
252251 assert ( Aig_ObjIsNode (pObjNew ) );
252+ // ensure reverse levels array is large enough for all objects
253+ Vec_IntFillExtra ( p -> vLevelR , Aig_ManObjNumMax (p ), 0 );
253254 // allocate level if needed
254255 if ( p -> vLevels == NULL )
255256 p -> vLevels = Vec_VecAlloc ( Aig_ManLevels (p ) + 8 );
0 commit comments