Commit 80b8b25a by Alan Mishchenko

Bug fix in the DSD manager writing and reading.

parent f0b67951
...@@ -835,11 +835,12 @@ void If_DsdManSave( If_DsdMan_t * p, char * pFileName ) ...@@ -835,11 +835,12 @@ void If_DsdManSave( If_DsdMan_t * p, char * pFileName )
fwrite( &Num, 4, 1, pFile ); fwrite( &Num, 4, 1, pFile );
fwrite( pObj, sizeof(word)*Num, 1, pFile ); fwrite( pObj, sizeof(word)*Num, 1, pFile );
} }
assert( Vec_MemEntryNum(p->vTtMem) == Vec_PtrSize(p->vTtDecs) );
Num = Vec_MemEntryNum(p->vTtMem); Num = Vec_MemEntryNum(p->vTtMem);
fwrite( &Num, 4, 1, pFile ); fwrite( &Num, 4, 1, pFile );
Vec_MemForEachEntry( p->vTtMem, pTruth, i ) Vec_MemForEachEntry( p->vTtMem, pTruth, i )
fwrite( pTruth, sizeof(word)*p->nWords, 1, pFile ); fwrite( pTruth, sizeof(word)*p->nWords, 1, pFile );
Num = Vec_PtrSize(p->vTtDecs);
fwrite( &Num, 4, 1, pFile );
Vec_PtrForEachEntry( Vec_Int_t *, p->vTtDecs, vSets, i ) Vec_PtrForEachEntry( Vec_Int_t *, p->vTtDecs, vSets, i )
{ {
Num = Vec_IntSize(vSets); Num = Vec_IntSize(vSets);
...@@ -856,7 +857,7 @@ If_DsdMan_t * If_DsdManLoad( char * pFileName ) ...@@ -856,7 +857,7 @@ If_DsdMan_t * If_DsdManLoad( char * pFileName )
char pBuffer[10]; char pBuffer[10];
unsigned * pSpot; unsigned * pSpot;
word * pTruth; word * pTruth;
int i, Num, RetValue; int i, Num, Num2, RetValue;
FILE * pFile = fopen( pFileName, "rb" ); FILE * pFile = fopen( pFileName, "rb" );
if ( pFile == NULL ) if ( pFile == NULL )
{ {
...@@ -904,7 +905,8 @@ If_DsdMan_t * If_DsdManLoad( char * pFileName ) ...@@ -904,7 +905,8 @@ If_DsdMan_t * If_DsdManLoad( char * pFileName )
} }
ABC_FREE( pTruth ); ABC_FREE( pTruth );
assert( Num == Vec_MemEntryNum(p->vTtMem) ); assert( Num == Vec_MemEntryNum(p->vTtMem) );
for ( i = 0; i < Vec_MemEntryNum(p->vTtMem); i++ ) RetValue = fread( &Num2, 4, 1, pFile );
for ( i = 0; i < Num2; i++ )
{ {
RetValue = fread( &Num, 4, 1, pFile ); RetValue = fread( &Num, 4, 1, pFile );
vSets = Vec_IntAlloc( Num ); vSets = Vec_IntAlloc( Num );
...@@ -912,7 +914,7 @@ If_DsdMan_t * If_DsdManLoad( char * pFileName ) ...@@ -912,7 +914,7 @@ If_DsdMan_t * If_DsdManLoad( char * pFileName )
vSets->nSize = Num; vSets->nSize = Num;
Vec_PtrPush( p->vTtDecs, vSets ); Vec_PtrPush( p->vTtDecs, vSets );
} }
assert( Vec_MemEntryNum(p->vTtMem) == Vec_PtrSize(p->vTtDecs) ); assert( Num2 == Vec_PtrSize(p->vTtDecs) );
fclose( pFile ); fclose( pFile );
return p; return p;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment