diff options
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/util/utilNam.c | 21 | ||||
-rw-r--r-- | src/misc/vec/vecStr.h | 12 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/misc/util/utilNam.c b/src/misc/util/utilNam.c index 76c86aff..96c3b283 100644 --- a/src/misc/util/utilNam.c +++ b/src/misc/util/utilNam.c @@ -257,7 +257,7 @@ int Abc_NamStrHash( const char * pStr, const char * pLim, int nTableSize ) unsigned i, uHash; if ( pLim ) { - for ( uHash = 0, i = 0; pStr < pLim; i++ ) + for ( uHash = 0, i = 0; pStr+i < pLim; i++ ) if ( i & 1 ) uHash *= pStr[i] * s_FPrimes[i & 0x7F]; else @@ -285,6 +285,23 @@ int Abc_NamStrHash( const char * pStr, const char * pLim, int nTableSize ) SeeAlso [] ***********************************************************************/ +static inline int Abc_NamStrcmp( char * pStr, char * pLim, char * pThis ) +{ + if ( pLim ) + { + while ( pStr < pLim ) + if ( *pStr++ != *pThis++ ) + return 1; + return *pThis != '\0'; + } + else + { + while ( *pStr ) + if ( *pStr++ != *pThis++ ) + return 1; + return *pThis != '\0'; + } +} static inline int * Abc_NamStrHashFind( Abc_Nam_t * p, const char * pStr, const char * pLim ) { char * pThis; @@ -293,7 +310,7 @@ static inline int * Abc_NamStrHashFind( Abc_Nam_t * p, const char * pStr, const for ( pThis = (*pPlace)? Abc_NamIntToStr(p, *pPlace) : NULL; pThis; pPlace = Abc_NamIntToNextP(p, *pPlace), pThis = (*pPlace)? Abc_NamIntToStr(p, *pPlace) : NULL ) - if ( !strcmp( pStr, pThis ) ) + if ( !Abc_NamStrcmp( (char *)pStr, (char *)pLim, pThis ) ) break; return pPlace; } diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h index f8452bdd..5f04615c 100644 --- a/src/misc/vec/vecStr.h +++ b/src/misc/vec/vecStr.h @@ -201,6 +201,18 @@ static inline Vec_Str_t * Vec_StrDupArray( Vec_Str_t * pVec ) SeeAlso [] ***********************************************************************/ +static inline void Vec_StrZero( Vec_Str_t * p ) +{ + p->pArray = NULL; + p->nSize = 0; + p->nCap = 0; +} +static inline void Vec_StrErase( Vec_Str_t * p ) +{ + ABC_FREE( p->pArray ); + p->nSize = 0; + p->nCap = 0; +} static inline void Vec_StrFree( Vec_Str_t * p ) { ABC_FREE( p->pArray ); |