summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2011-03-27 14:17:12 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2011-03-27 14:17:12 -0700
commit6c01e8b9f040d591f72882aff08ed21446fbb567 (patch)
tree71f04dae22291d7321e5bb244462ab1145c47ee6 /src/base
parent1ec437d04b2fcb42054f068525c2a1b21b69fe53 (diff)
downloadabc-6c01e8b9f040d591f72882aff08ed21446fbb567.tar.gz
abc-6c01e8b9f040d591f72882aff08ed21446fbb567.tar.bz2
abc-6c01e8b9f040d591f72882aff08ed21446fbb567.zip
Fixed a number of small bugs and memory leaks.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/abc/abcBlifMv.c2
-rw-r--r--src/base/abc/abcFunc.c1
-rw-r--r--src/base/abc/abcSop.c1
-rw-r--r--src/base/abc/abcUtil.c11
-rw-r--r--src/base/abci/abc.c10
-rw-r--r--src/base/abci/abcDsd.c7
-rw-r--r--src/base/abci/abcVerify.c2
-rw-r--r--src/base/cmd/cmd.c2
-rw-r--r--src/base/cmd/cmdLoad.c3
-rw-r--r--src/base/io/io.c1
-rw-r--r--src/base/io/ioReadBlif.c2
-rw-r--r--src/base/io/ioReadBlifAig.c1
-rw-r--r--src/base/io/ioReadBlifMv.c1
-rw-r--r--src/base/io/ioReadPla.c10
-rw-r--r--src/base/io/ioWriteAiger.c2
-rw-r--r--src/base/io/ioWriteBook.c1
-rw-r--r--src/base/ver/verCore.c5
17 files changed, 49 insertions, 13 deletions
diff --git a/src/base/abc/abcBlifMv.c b/src/base/abc/abcBlifMv.c
index 21535cb5..cffdc8da 100644
--- a/src/base/abc/abcBlifMv.c
+++ b/src/base/abc/abcBlifMv.c
@@ -228,11 +228,13 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
}
if ( *pSop == '!' )
{
+ ABC_FREE( pValues );
printf( "Abc_NodeStrashBlifMv(): Cannot handle complement in the MV function of node %s.\n", Abc_ObjName(Abc_ObjFanout0(pObj)) );
return 0;
}
if ( *pSop == '{' )
{
+ ABC_FREE( pValues );
printf( "Abc_NodeStrashBlifMv(): Cannot handle braces in the MV function of node %s.\n", Abc_ObjName(Abc_ObjFanout0(pObj)) );
return 0;
}
diff --git a/src/base/abc/abcFunc.c b/src/base/abc/abcFunc.c
index 81990bac..7ff7db17 100644
--- a/src/base/abc/abcFunc.c
+++ b/src/base/abc/abcFunc.c
@@ -572,6 +572,7 @@ int Abc_NtkSopToAig( Abc_Ntk_t * pNtk )
pNode->pData = Abc_ConvertSopToAig( pMan, (char *)pNode->pData );
if ( pNode->pData == NULL )
{
+ Hop_ManStop( pMan );
printf( "Abc_NtkSopToAig: Error while converting SOP into AIG.\n" );
return 0;
}
diff --git a/src/base/abc/abcSop.c b/src/base/abc/abcSop.c
index 2a4cf7d2..424f6bd1 100644
--- a/src/base/abc/abcSop.c
+++ b/src/base/abc/abcSop.c
@@ -900,6 +900,7 @@ char * Abc_SopFromTruthBin( char * pTruth )
Digit = pTruth[i] - '0';
else
{
+ Vec_IntFree( vMints );
printf( "String %s does not look like a binary representation of the truth table.\n", pTruth );
return NULL;
}
diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c
index e063a238..1e5777b9 100644
--- a/src/base/abc/abcUtil.c
+++ b/src/base/abc/abcUtil.c
@@ -1851,13 +1851,20 @@ void Abc_NtkCompareCones( Abc_Ntk_t * pNtk )
printf( "%4d CO %5d : Supp = %5d. Lev = %3d. Cone = %5d. Rev = %5d. COs = %3d (%3d).\n",
Iter, pPerms[i], Vec_PtrSize(vSupp), Abc_ObjLevel(Abc_ObjFanin0(pObj)), Vec_PtrSize(vNodes), Counter, CounterCos, CounterCosNew );
+ if ( Vec_PtrSize(vSupp) < 10 )
+ {
+ // free arrays
+ Vec_PtrFree( vSupp );
+ Vec_PtrFree( vNodes );
+ Vec_PtrFree( vReverse );
+ break;
+ }
+
// free arrays
Vec_PtrFree( vSupp );
Vec_PtrFree( vNodes );
Vec_PtrFree( vReverse );
- if ( Vec_PtrSize(vSupp) < 10 )
- break;
}
Abc_NtkForEachCo( pNtk, pObj, i )
pObj->fMarkA = 0;
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 8443ef83..b8c8f7a0 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -2103,7 +2103,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
// convert it to truth table
{
Abc_Obj_t * pObj = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
- Vec_Int_t * vMemory = Vec_IntAlloc(0);
+ Vec_Int_t * vMemory;
unsigned * pTruth;
if ( !Abc_ObjIsNode(pObj) )
{
@@ -2115,6 +2115,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Currently works only for up to 16 inputs.\n" );
return 1;
}
+ vMemory = Vec_IntAlloc(0);
pTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNtk->pManFunc, Hop_Regular((Hop_Obj_t *)pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 0 );
if ( Hop_IsComplement((Hop_Obj_t *)pObj->pData) )
Extra_TruthNot( pTruth, pTruth, Abc_ObjFaninNum(pObj) );
@@ -5581,7 +5582,7 @@ usage:
int Abc_CommandOrPos( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
- int fComb;
+ int fComb = 0;
int c;
extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd );
@@ -5656,7 +5657,7 @@ usage:
int Abc_CommandAndPos( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
- int fComb;
+ int fComb = 0;
int c;
// set defaults
@@ -5932,7 +5933,7 @@ int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pNtk2;
char * FileName;
- int fComb;
+ int fComb = 0;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
@@ -5972,6 +5973,7 @@ int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
// check if the second network is combinational
if ( Abc_NtkLatchNum(pNtk2) )
{
+ Abc_NtkDelete( pNtk2 );
Abc_Print( -1, "The second network has latches. Appending does not work for such networks.\n" );
return 0;
}
diff --git a/src/base/abci/abcDsd.c b/src/base/abci/abcDsd.c
index 558d9349..250cac14 100644
--- a/src/base/abci/abcDsd.c
+++ b/src/base/abci/abcDsd.c
@@ -113,14 +113,15 @@ Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int
// perform the decomposition
dd = (DdManager *)Abc_NtkGlobalBddMan(pNtk);
pManDsd = Dsd_ManagerStart( dd, Abc_NtkCiNum(pNtk), fVerbose );
- Dsd_Decompose( pManDsd, (DdNode **)vFuncsGlob->pArray, Abc_NtkCoNum(pNtk) );
- Vec_PtrFree( vFuncsGlob );
- Abc_NtkFreeGlobalBdds( pNtk, 0 );
if ( pManDsd == NULL )
{
+ Vec_PtrFree( vFuncsGlob );
Cudd_Quit( dd );
return NULL;
}
+ Dsd_Decompose( pManDsd, (DdNode **)vFuncsGlob->pArray, Abc_NtkCoNum(pNtk) );
+ Vec_PtrFree( vFuncsGlob );
+ Abc_NtkFreeGlobalBdds( pNtk, 0 );
// start the new network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
diff --git a/src/base/abci/abcVerify.c b/src/base/abci/abcVerify.c
index acdfcd93..7a9a5239 100644
--- a/src/base/abci/abcVerify.c
+++ b/src/base/abci/abcVerify.c
@@ -1031,7 +1031,7 @@ int Abc_NtkIsTrueCex( Abc_Ntk_t * pNtk, Abc_Cex_t * pCex )
{
extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
Aig_Man_t * pMan;
- int status, fStrashed = 0;
+ int status = 0, fStrashed = 0;
if ( !Abc_NtkIsStrash(pNtk) )
{
pNtk = Abc_NtkStrash(pNtk, 0, 0, 0);
diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c
index 15cbdda5..35eb535a 100644
--- a/src/base/cmd/cmd.c
+++ b/src/base/cmd/cmd.c
@@ -671,7 +671,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
}
if ( interactive && *line != '\0' )
{
- Cmd_HistoryAddCommand( pAbc, Extra_UtilStrsav(line) );
+ Cmd_HistoryAddCommand( pAbc, line );
if ( pAbc->Hst != NULL )
{
fprintf( pAbc->Hst, "%s\n", line );
diff --git a/src/base/cmd/cmdLoad.c b/src/base/cmd/cmdLoad.c
index b96737c6..797275db 100644
--- a/src/base/cmd/cmdLoad.c
+++ b/src/base/cmd/cmdLoad.c
@@ -58,6 +58,7 @@ int CmdCommandLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
// check if there is the binary
if ( (pFile = fopen( Vec_StrArray(vCommand), "r" )) == NULL )
{
+ Vec_StrFree( vCommand );
Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", Vec_StrArray(vCommand) );
return 1;
}
@@ -73,10 +74,12 @@ int CmdCommandLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
// run the command line
if ( Util_SignalSystem( Vec_StrArray(vCommand) ) )
{
+ Vec_StrFree( vCommand );
Abc_Print( -1, "The following command has returned non-zero exit status:\n" );
Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) );
return 1;
}
+ Vec_StrFree( vCommand );
return 0;
}
diff --git a/src/base/io/io.c b/src/base/io/io.c
index 46cbb33a..1230cd8e 100644
--- a/src/base/io/io.c
+++ b/src/base/io/io.c
@@ -933,6 +933,7 @@ int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
pSopCover = Abc_SopFromTruthBin(argv[globalUtilOptind]);
if ( pSopCover == NULL || pSopCover[0] == 0 )
{
+ ABC_FREE( pSopCover );
fprintf( pAbc->Err, "Reading truth table has failed.\n" );
return 1;
}
diff --git a/src/base/io/ioReadBlif.c b/src/base/io/ioReadBlif.c
index a1241354..9fd41261 100644
--- a/src/base/io/ioReadBlif.c
+++ b/src/base/io/ioReadBlif.c
@@ -149,9 +149,9 @@ Abc_Ntk_t * Io_ReadBlifNetwork( Io_ReadBlif_t * p )
if ( p->vTokens && strcmp((char *)p->vTokens->pArray[0], ".exdc") == 0 )
{
pNtk->pExdc = Io_ReadBlifNetworkOne( p );
- Abc_NtkFinalizeRead( pNtk->pExdc );
if ( pNtk->pExdc == NULL )
break;
+ Abc_NtkFinalizeRead( pNtk->pExdc );
}
// add this network as part of the hierarchy
if ( pNtkMaster == NULL ) // no master network so far
diff --git a/src/base/io/ioReadBlifAig.c b/src/base/io/ioReadBlifAig.c
index caa776f9..1ef61196 100644
--- a/src/base/io/ioReadBlifAig.c
+++ b/src/base/io/ioReadBlifAig.c
@@ -444,6 +444,7 @@ static char * Io_BlifLoadFile( char * pFileName )
nFileSize = ftell( pFile );
if ( nFileSize == 0 )
{
+ fclose( pFile );
printf( "Io_BlifLoadFile(): The file is empty.\n" );
return NULL;
}
diff --git a/src/base/io/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c
index c3612b2d..1c28ac3d 100644
--- a/src/base/io/ioReadBlifMv.c
+++ b/src/base/io/ioReadBlifMv.c
@@ -538,6 +538,7 @@ static char * Io_MvLoadFile( char * pFileName )
nFileSize = ftell( pFile );
if ( nFileSize == 0 )
{
+ fclose( pFile );
printf( "Io_MvLoadFile(): The file is empty.\n" );
return NULL;
}
diff --git a/src/base/io/ioReadPla.c b/src/base/io/ioReadPla.c
index 36d44c68..927cf7e5 100644
--- a/src/base/io/ioReadPla.c
+++ b/src/base/io/ioReadPla.c
@@ -120,6 +120,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
printf( "%s (line %d): Wrong number of token.\n",
Extra_FileReaderGetFileName(p), iLine+1 );
Abc_NtkDelete( pNtk );
+ Extra_ProgressBarStop( pProgress );
+ ABC_FREE( ppSops );
return NULL;
}
@@ -152,6 +154,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
{
printf( "%s: The number of inputs is not specified.\n", Extra_FileReaderGetFileName(p) );
Abc_NtkDelete( pNtk );
+ Extra_ProgressBarStop( pProgress );
+ ABC_FREE( ppSops );
return NULL;
}
nDigits = Extra_Base10Log( nInputs );
@@ -167,6 +171,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
{
printf( "%s: The number of outputs is not specified.\n", Extra_FileReaderGetFileName(p) );
Abc_NtkDelete( pNtk );
+ Extra_ProgressBarStop( pProgress );
+ ABC_FREE( ppSops );
return NULL;
}
nDigits = Extra_Base10Log( nOutputs );
@@ -199,6 +205,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
printf( "%s (line %d): Input and output cubes are not specified.\n",
Extra_FileReaderGetFileName(p), iLine+1 );
Abc_NtkDelete( pNtk );
+ Extra_ProgressBarStop( pProgress );
+ ABC_FREE( ppSops );
return NULL;
}
pCubeIn = (char *)vTokens->pArray[0];
@@ -215,6 +223,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
printf( "%s (line %d): Output cube length (%zu) differs from the number of outputs (%d).\n",
Extra_FileReaderGetFileName(p), iLine+1, strlen(pCubeOut), nOutputs );
Abc_NtkDelete( pNtk );
+ Extra_ProgressBarStop( pProgress );
+ ABC_FREE( ppSops );
return NULL;
}
if ( fZeros )
diff --git a/src/base/io/ioWriteAiger.c b/src/base/io/ioWriteAiger.c
index 3900cf26..1087af4f 100644
--- a/src/base/io/ioWriteAiger.c
+++ b/src/base/io/ioWriteAiger.c
@@ -668,6 +668,7 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f
fprintf( stdout, "Io_WriteAiger(): I/O error writing to compressed stream.\n" );
fclose( b.f );
ABC_FREE(b.buf);
+ Vec_StrFree( vBinary );
return;
}
}
@@ -694,6 +695,7 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f
printf( "Io_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
fclose( b.f );
ABC_FREE(b.buf);
+ Extra_ProgressBarStop( pProgress );
return;
}
}
diff --git a/src/base/io/ioWriteBook.c b/src/base/io/ioWriteBook.c
index 9d0df473..45807ce6 100644
--- a/src/base/io/ioWriteBook.c
+++ b/src/base/io/ioWriteBook.c
@@ -117,6 +117,7 @@ void Io_WriteBook( Abc_Ntk_t * pNtk, char * FileName )
// write the aux file
if ( (pFileNodes == NULL) || (pFileNets == NULL) || (pFileAux == NULL) )
{
+ fclose( pFileAux );
fprintf( stdout, "Io_WriteBook(): Cannot open the output files.\n" );
return;
}
diff --git a/src/base/ver/verCore.c b/src/base/ver/verCore.c
index bb7142f3..eb036620 100644
--- a/src/base/ver/verCore.c
+++ b/src/base/ver/verCore.c
@@ -109,7 +109,10 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib )
p->pFileName = pFileName;
p->pReader = Ver_StreamAlloc( pFileName );
if ( p->pReader == NULL )
+ {
+ ABC_FREE( p );
return NULL;
+ }
p->Output = stdout;
p->vNames = Vec_PtrAlloc( 100 );
p->vStackFn = Vec_PtrAlloc( 100 );
@@ -2537,7 +2540,7 @@ int Ver_ParseDriveFormal( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_Bundle_t * pBu
Abc_ObjAddFanin( pNetAct, pTermNew );
}
// remove the bundle
- Ver_ParseFreeBundle( pBundle );
+ Ver_ParseFreeBundle( pBundle ); pBundle = NULL;
Vec_PtrWriteEntry( (Vec_Ptr_t *)pBox->pCopy, j, NULL );
}
ABC_FREE( pName );