Go to the source code of this file.
|
| Abc_Nam_t * | Abc_NamStart (int nObjs, int nAveSize) |
| | FUNCTION DECLARATIONS ///.
|
| |
| void | Abc_NamStop (Abc_Nam_t *p) |
| |
| void | Abc_NamPrint (Abc_Nam_t *p, char *pFileName) |
| |
| void | Abc_NamSave (Abc_Nam_t *p, char *pFileName) |
| |
| Abc_Nam_t * | Abc_NamLoad (char *pFileName) |
| |
| Abc_Nam_t * | Abc_NamRef (Abc_Nam_t *p) |
| |
| void | Abc_NamDeref (Abc_Nam_t *p) |
| |
| int | Abc_NamObjNumMax (Abc_Nam_t *p) |
| |
| int | Abc_NamMemUsed (Abc_Nam_t *p) |
| |
| int | Abc_NamMemAlloc (Abc_Nam_t *p) |
| |
| int | Abc_NamStrFind (Abc_Nam_t *p, char *pStr) |
| |
| int | Abc_NamStrFindLim (Abc_Nam_t *p, char *pStr, char *pLim) |
| |
| int | Abc_NamStrFindOrAdd (Abc_Nam_t *p, char *pStr, int *pfFound) |
| |
| int | Abc_NamStrFindOrAddLim (Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound) |
| |
| int | Abc_NamStrFindOrAddF (Abc_Nam_t *p, const char *format,...) |
| |
| char * | Abc_NamStr (Abc_Nam_t *p, int id) |
| |
| Vec_Str_t * | Abc_NamBuffer (Abc_Nam_t *p) |
| |
| Vec_Int_t * | Abc_NamComputeIdMap (Abc_Nam_t *p1, Abc_Nam_t *p2) |
| |
| int | Abc_NamReportCommon (Vec_Int_t *vNameIds1, Abc_Nam_t *p1, Abc_Nam_t *p2) |
| |
| char * | Abc_NamReportUnique (Vec_Int_t *vNameIds1, Abc_Nam_t *p1, Abc_Nam_t *p2) |
| |
◆ Abc_NamManForEachObj
| #define Abc_NamManForEachObj |
( |
| p, |
|
|
| pStr, |
|
|
| i ) |
Value:
int Abc_NamObjNumMax(Abc_Nam_t *p)
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
MACRO DEFINITIONS ///.
Definition at line 45 of file utilNam.h.
45#define Abc_NamManForEachObj( p, pStr, i ) \
46 for ( i = 1; (i < Abc_NamObjNumMax(p)) && ((pStr) = Abc_NamStr(p, i)); i++ )
◆ Abc_Nam_t
INCLUDES ///.
CFile****************************************************************
FileName [utilNam.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Memory recycling utilities.]
Synopsis [Internal declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [
- Id
- utilNam.h,v 1.00 2005/06/20 00:00:00 alanmi Exp
] PARAMETERS /// BASIC TYPES ///
Definition at line 39 of file utilNam.h.
◆ Abc_NamBuffer()
Function*************************************************************
Synopsis [Returns internal buffer.]
Description []
SideEffects []
SeeAlso []
Definition at line 571 of file utilNam.c.
572{
573 Vec_StrClear(&
p->vBuffer);
575}
◆ Abc_NamComputeIdMap()
Function*************************************************************
Synopsis [For each ID of the first manager, gives ID of the second one.]
Description []
SideEffects []
SeeAlso []
Definition at line 588 of file utilNam.c.
589{
591 char * pThis;
592 int * piPlace, iHandle1, i;
593 if ( p1 == p2 )
597 {
598 pThis = Abc_NamHandleToStr( p1, iHandle1 );
599 piPlace = Abc_NamStrHashFind( p2, pThis, NULL );
600 Vec_IntWriteEntry( vMap, i, *piPlace );
601
602 }
603 return vMap;
604}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
◆ Abc_NamDeref()
Function*************************************************************
Synopsis [Dereferences the manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 212 of file utilNam.c.
213{
215 return;
216 if ( --
p->nRefs == 0 )
218}
void Abc_NamStop(Abc_Nam_t *p)
◆ Abc_NamLoad()
Definition at line 164 of file utilNam.c.
165{
167 int fFound, NameId = -1, nLineSize = 1 << 20;
168 char * pBuffer =
ABC_ALLOC(
char, nLineSize+1 );
169 FILE * pFile = fopen( pFileName, "rb" );
170 if ( pFile == NULL ) { printf( "Count node open output file %s\n", pFileName ); return NULL; }
172 while ( fgets( pBuffer, nLineSize, pFile ) != NULL )
173 {
174 pBuffer[
strlen(pBuffer)-1] = 0;
177 }
179 fclose( pFile );
182}
#define ABC_ALLOC(type, num)
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
◆ Abc_NamMemAlloc()
Function*************************************************************
Synopsis [Reports memory usage of the manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 266 of file utilNam.c.
267{
269 return 0;
270 return sizeof(
Abc_Nam_t) +
p->nStore +
sizeof(
int) *
p->nBins +
271 sizeof(int) * (
p->vInt2Handle.nCap +
p->vInt2Next.nCap);
272}
◆ Abc_NamMemUsed()
Function*************************************************************
Synopsis [Reports memory usage of the manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 247 of file utilNam.c.
248{
250 return 0;
251 return sizeof(
Abc_Nam_t) +
p->iHandle +
sizeof(
int) *
p->nBins +
252 sizeof(int) * (
p->vInt2Handle.nSize +
p->vInt2Next.nSize);
253}
◆ Abc_NamObjNumMax()
Function*************************************************************
Synopsis [Returns the number of used entries.]
Description []
SideEffects []
SeeAlso []
Definition at line 231 of file utilNam.c.
232{
233 return Vec_IntSize(&
p->vInt2Handle);
234}
◆ Abc_NamPrint()
| void Abc_NamPrint |
( |
Abc_Nam_t * | p, |
|
|
char * | pFileName ) |
|
extern |
Function*************************************************************
Synopsis [Prints manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 134 of file utilNam.c.
135{
136 FILE * pFile = pFileName ? fopen( pFileName, "wb" ) : stdout;
137 int h, i;
138 if ( pFile == NULL ) { printf( "Count node open file %s\n", pFileName ); return; }
140 fprintf( pFile,
"%8d = %s\n", i, Abc_NamHandleToStr(
p, h) );
141 if ( pFile != stdout )
142 fclose(pFile);
143}
◆ Abc_NamRef()
Function*************************************************************
Synopsis [References the manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 195 of file utilNam.c.
◆ Abc_NamReportCommon()
Function*************************************************************
Synopsis [Returns the number of common names in the array.]
Description [The array contains name IDs in the first manager. The procedure returns the number of entries that correspond to names in the first manager that appear in the second manager.]
SideEffects []
SeeAlso []
Definition at line 619 of file utilNam.c.
620{
621 int i, Entry, Counter = 0;
623 {
626
627
628 }
629 return Counter;
630}
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
◆ Abc_NamReportUnique()
Function*************************************************************
Synopsis [Returns the name that appears in p1 does not appear in p2.]
Description []
SideEffects []
SeeAlso []
Definition at line 643 of file utilNam.c.
644{
645 int i, Entry;
647 {
651 }
652 return NULL;
653}
◆ Abc_NamSave()
| void Abc_NamSave |
( |
Abc_Nam_t * | p, |
|
|
char * | pFileName ) |
|
extern |
Function*************************************************************
Synopsis [Writes into a file and reads from a file.]
Description []
SideEffects []
SeeAlso []
Definition at line 156 of file utilNam.c.
157{
158 FILE * pFile = fopen( pFileName, "wb" ); int h, i;
159 if ( pFile == NULL ) { printf( "Count node open input file %s\n", pFileName ); return; }
161 fprintf( pFile,
"%s\n", Abc_NamHandleToStr(
p, h) );
162 fclose(pFile);
163}
◆ Abc_NamStart()
| Abc_Nam_t * Abc_NamStart |
( |
int | nObjs, |
|
|
int | nAveSize ) |
|
extern |
FUNCTION DECLARATIONS ///.
FUNCTION DECLARATIONS ///.
Function*************************************************************
Synopsis [Creates manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 80 of file utilNam.c.
81{
83 if ( nObjs == 0 )
84 nObjs = 16;
86 p->nStore = ((nObjs * (nAveSize + 1) + 16) / 4) * 4;
88 p->nBins = Abc_PrimeCudd( nObjs );
90
91 Vec_IntGrow( &
p->vInt2Handle, nObjs ); Vec_IntPush( &
p->vInt2Handle, -1 );
92 Vec_IntGrow( &
p->vInt2Next, nObjs ); Vec_IntPush( &
p->vInt2Next, -1 );
95
96
99}
#define ABC_CALLOC(type, num)
◆ Abc_NamStop()
Function*************************************************************
Synopsis [Deletes manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 112 of file utilNam.c.
113{
114
115 Vec_StrErase( &
p->vBuffer );
116 Vec_IntErase( &
p->vInt2Handle );
117 Vec_IntErase( &
p->vInt2Next );
121}
◆ Abc_NamStr()
| char * Abc_NamStr |
( |
Abc_Nam_t * | p, |
|
|
int | NameId ) |
|
extern |
Function*************************************************************
Synopsis [Returns name from name ID.]
Description []
SideEffects []
SeeAlso []
Definition at line 555 of file utilNam.c.
556{
557 return NameId > 0 ? Abc_NamIntToStr(
p, NameId) : NULL;
558}
◆ Abc_NamStrFind()
| int Abc_NamStrFind |
( |
Abc_Nam_t * | p, |
|
|
char * | pStr ) |
|
extern |
Function*************************************************************
Synopsis [Returns the index of the string in the table.]
Description []
SideEffects []
SeeAlso []
Definition at line 433 of file utilNam.c.
434{
435 return *Abc_NamStrHashFind(
p, pStr, NULL );
436}
◆ Abc_NamStrFindLim()
| int Abc_NamStrFindLim |
( |
Abc_Nam_t * | p, |
|
|
char * | pStr, |
|
|
char * | pLim ) |
|
extern |
Definition at line 437 of file utilNam.c.
438{
439 return *Abc_NamStrHashFind(
p, pStr, pLim );
440}
◆ Abc_NamStrFindOrAdd()
| int Abc_NamStrFindOrAdd |
( |
Abc_Nam_t * | p, |
|
|
char * | pStr, |
|
|
int * | pfFound ) |
|
extern |
Function*************************************************************
Synopsis [Finds or adds the given name to storage.]
Description []
SideEffects []
SeeAlso []
Definition at line 453 of file utilNam.c.
454{
455 int i, iHandleNew;
456 int *piPlace;
457 if ( !(pStr[0] !=
'\\' || pStr[
strlen(pStr)-1] ==
' ') )
458 {
459 for ( i =
strlen(pStr) - 1; i >= 0; i-- )
460 if ( *pStr == ' ' )
461 break;
463 }
464 piPlace = Abc_NamStrHashFind(
p, pStr, NULL );
465 if ( *piPlace )
466 {
467 if ( pfFound )
468 *pfFound = 1;
469 return *piPlace;
470 }
471 if ( pfFound )
472 *pfFound = 0;
473 iHandleNew =
p->iHandle +
strlen(pStr) + 1;
474 while (
p->nStore < iHandleNew )
475 {
479 }
480 assert(
p->nStore >= iHandleNew );
481
482 *piPlace = Vec_IntSize( &
p->vInt2Handle );
483 strcpy( Abc_NamHandleToStr(
p,
p->iHandle ), pStr );
484 Vec_IntPush( &
p->vInt2Handle,
p->iHandle );
485 Vec_IntPush( &
p->vInt2Next, 0 );
486 p->iHandle = iHandleNew;
487
488 if ( Vec_IntSize(&
p->vInt2Handle) > 2 *
p->nBins )
490 return Vec_IntSize(&
p->vInt2Handle) - 1;
491}
#define ABC_REALLOC(type, obj, num)
void Abc_NamStrHashResize(Abc_Nam_t *p)
◆ Abc_NamStrFindOrAddF()
Definition at line 528 of file utilNam.c.
529{
530 int nAdded, nSize = 1000;
531 va_list args; va_start( args, format );
532 Vec_StrGrow( &
p->vBuffer, Vec_StrSize(&
p->vBuffer) + nSize );
533 nAdded = vsnprintf( Vec_StrLimit(&
p->vBuffer), nSize, format, args );
534 if ( nAdded > nSize )
535 {
536 Vec_StrGrow( &
p->vBuffer, Vec_StrSize(&
p->vBuffer) + nAdded + nSize );
537 nSize = vsnprintf( Vec_StrLimit(&
p->vBuffer), nAdded, format, args );
538 assert( nSize == nAdded );
539 }
540 va_end( args );
542}
int Abc_NamStrFindOrAddLim(Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
◆ Abc_NamStrFindOrAddLim()
| int Abc_NamStrFindOrAddLim |
( |
Abc_Nam_t * | p, |
|
|
char * | pStr, |
|
|
char * | pLim, |
|
|
int * | pfFound ) |
|
extern |
Definition at line 492 of file utilNam.c.
493{
494 int iHandleNew;
495 int *piPlace;
496 char * pStore;
498 piPlace = Abc_NamStrHashFind(
p, pStr, pLim );
499 if ( *piPlace )
500 {
501 if ( pfFound )
502 *pfFound = 1;
503 return *piPlace;
504 }
505 if ( pfFound )
506 *pfFound = 0;
507 iHandleNew =
p->iHandle + (pLim - pStr) + 1;
508 while (
p->nStore < iHandleNew )
509 {
513 }
514 assert(
p->nStore >= iHandleNew );
515
516 *piPlace = Vec_IntSize( &
p->vInt2Handle );
517 pStore = Abc_NamHandleToStr(
p,
p->iHandle );
518 strncpy( pStore, pStr, pLim - pStr );
519 pStore[pLim - pStr] = 0;
520 Vec_IntPush( &
p->vInt2Handle,
p->iHandle );
521 Vec_IntPush( &
p->vInt2Next, 0 );
522 p->iHandle = iHandleNew;
523
524 if ( Vec_IntSize(&
p->vInt2Handle) > 2 *
p->nBins )
526 return Vec_IntSize(&
p->vInt2Handle) - 1;
527}