summaryrefslogtreecommitdiffstats
path: root/src/aig/ioa
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2009-02-15 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2009-02-15 08:01:00 -0800
commit0871bffae307e0553e0c5186336189e8b55cf6a6 (patch)
tree4571d1563fe33a53a57fea1c35fb668b9d33265f /src/aig/ioa
parentf936cc0680c98ffe51b3a1716c996072d5dbf76c (diff)
downloadabc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.gz
abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.bz2
abc-0871bffae307e0553e0c5186336189e8b55cf6a6.zip
Version abc90215
Diffstat (limited to 'src/aig/ioa')
-rw-r--r--src/aig/ioa/ioa.h8
-rw-r--r--src/aig/ioa/ioaReadAig.c7
-rw-r--r--src/aig/ioa/ioaWriteAig.c12
3 files changed, 17 insertions, 10 deletions
diff --git a/src/aig/ioa/ioa.h b/src/aig/ioa/ioa.h
index be8594e7..55d95f6e 100644
--- a/src/aig/ioa/ioa.h
+++ b/src/aig/ioa/ioa.h
@@ -21,10 +21,6 @@
#ifndef __IOA_H__
#define __IOA_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -43,6 +39,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ioa/ioaReadAig.c b/src/aig/ioa/ioaReadAig.c
index 342bd9fa..11c866f4 100644
--- a/src/aig/ioa/ioaReadAig.c
+++ b/src/aig/ioa/ioaReadAig.c
@@ -112,7 +112,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
// read the file into the buffer
nFileSize = Ioa_FileSize( pFileName );
pFile = fopen( pFileName, "rb" );
- pContents = ALLOC( char, nFileSize );
+ pContents = ABC_ALLOC( char, nFileSize );
fread( pContents, nFileSize, 1, pFile );
fclose( pFile );
@@ -120,6 +120,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') )
{
fprintf( stdout, "Wrong input file format.\n" );
+ free( pContents );
return NULL;
}
@@ -147,7 +148,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
pName = Ioa_FileNameGeneric( pFileName );
pNew->pName = Aig_UtilStrsav( pName );
// pNew->pSpec = Ioa_UtilStrsav( pFileName );
- free( pName );
+ ABC_FREE( pName );
// prepare the array of nodes
vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
@@ -342,7 +343,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
*/
// skipping the comments
- free( pContents );
+ ABC_FREE( pContents );
Vec_PtrFree( vNodes );
// remove the extra nodes
diff --git a/src/aig/ioa/ioaWriteAig.c b/src/aig/ioa/ioaWriteAig.c
index ec37b40e..3d37c0a7 100644
--- a/src/aig/ioa/ioaWriteAig.c
+++ b/src/aig/ioa/ioaWriteAig.c
@@ -329,7 +329,7 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int
// write the nodes into the buffer
Pos = 0;
nBufferSize = 6 * Aig_ManNodeNum(pMan) + 100; // skeptically assuming 3 chars per one AIG edge
- pBuffer = ALLOC( unsigned char, nBufferSize );
+ pBuffer = ABC_ALLOC( unsigned char, nBufferSize );
// pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(pMan) );
Aig_ManForEachNode( pMan, pObj, i )
{
@@ -337,7 +337,13 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int
uLit = Ioa_ObjMakeLit( Ioa_ObjAigerNum(pObj), 0 );
uLit0 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj) );
uLit1 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj) );
- assert( uLit0 < uLit1 );
+ assert( uLit0 != uLit1 );
+ if ( uLit0 > uLit1 )
+ {
+ int Temp = uLit0;
+ uLit0 = uLit1;
+ uLit1 = Temp;
+ }
Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit - uLit1 );
Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 );
if ( Pos > nBufferSize - 10 )
@@ -352,7 +358,7 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int
// write the buffer
fwrite( pBuffer, 1, Pos, pFile );
- free( pBuffer );
+ ABC_FREE( pBuffer );
/*
// write the symbol table
if ( fWriteSymbols )