diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2021-11-12 12:31:29 +0100 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2021-11-12 12:31:29 +0100 |
commit | d2d6bbd9f86f61fc9b5cc7d703e1386bbd6ad6a2 (patch) | |
tree | 071fb2118c158c748ff9969ef250affe7b9a3561 /src/misc/util/utilNam.c | |
parent | 4f5f73d18b137930fb3048c0b385c82fa078db38 (diff) | |
parent | 9b245d9f6910c048e9bbcf95ee5dee46f2f24f2c (diff) | |
download | abc-d2d6bbd9f86f61fc9b5cc7d703e1386bbd6ad6a2.tar.gz abc-d2d6bbd9f86f61fc9b5cc7d703e1386bbd6ad6a2.tar.bz2 abc-d2d6bbd9f86f61fc9b5cc7d703e1386bbd6ad6a2.zip |
Merge remote-tracking branch 'upstream/master' into yosys-experimental
Diffstat (limited to 'src/misc/util/utilNam.c')
-rw-r--r-- | src/misc/util/utilNam.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/misc/util/utilNam.c b/src/misc/util/utilNam.c index 30a68c63..f6539f03 100644 --- a/src/misc/util/utilNam.c +++ b/src/misc/util/utilNam.c @@ -144,6 +144,45 @@ void Abc_NamPrint( Abc_Nam_t * p, char * pFileName ) /**Function************************************************************* + Synopsis [Writes into a file and reads from a file.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_NamSave( Abc_Nam_t * p, char * pFileName ) +{ + FILE * pFile = fopen( pFileName, "wb" ); int h, i; + if ( pFile == NULL ) { printf( "Count node open input file %s\n", pFileName ); return; } + Vec_IntForEachEntryStart( &p->vInt2Handle, h, i, 1 ) + fprintf( pFile, "%s\n", Abc_NamHandleToStr(p, h) ); + fclose(pFile); +} +Abc_Nam_t * Abc_NamLoad( char * pFileName ) +{ + Abc_Nam_t * p; + int fFound, NameId = -1, nLineSize = 1 << 20; + char * pBuffer = ABC_ALLOC( char, nLineSize+1 ); + FILE * pFile = fopen( pFileName, "rb" ); + if ( pFile == NULL ) { printf( "Count node open output file %s\n", pFileName ); return NULL; } + p = Abc_NamStart( 1000, 20 ); + while ( fgets( pBuffer, nLineSize, pFile ) != NULL ) + { + pBuffer[strlen(pBuffer)-1] = 0; + NameId = Abc_NamStrFindOrAdd( p, pBuffer, &fFound ); + assert( !fFound ); + } + assert( NameId+1 == Abc_NamObjNumMax(p) ); + fclose( pFile ); + ABC_FREE( pBuffer ); + return p; +} + +/**Function************************************************************* + Synopsis [References the manager.] Description [] |