Commit cb439f2e by Alan Mishchenko

Bug fix in Vec_IntInsert() and a couple of new APIs.

parent 41d18ca0
......@@ -217,6 +217,24 @@ static inline void Prs_ManFinalizeNtk( Prs_Man_t * p )
p->pNtk = NULL;
}
static inline int Prs_NtkNewStrId( Prs_Ntk_t * pNtk, const char * format, ... )
{
Abc_Nam_t * p = pNtk->pStrs;
Vec_Str_t * vBuf = Abc_NamBuffer( p );
int nAdded, nSize = 1000;
va_list args; va_start( args, format );
Vec_StrGrow( vBuf, Vec_StrSize(vBuf) + nSize );
nAdded = vsnprintf( Vec_StrLimit(vBuf), nSize, format, args );
if ( nAdded > nSize )
{
Vec_StrGrow( vBuf, Vec_StrSize(vBuf) + nAdded + nSize );
nSize = vsnprintf( Vec_StrLimit(vBuf), nAdded, format, args );
assert( nSize == nAdded );
}
va_end( args );
return Abc_NamStrFindOrAddLim( p, Vec_StrLimit(vBuf), Vec_StrLimit(vBuf) + nAdded, NULL );
}
// parsing slice/concatentation/box
static inline int Prs_NtkAddSlice( Prs_Ntk_t * p, int Name, int Range )
{
......
......@@ -1013,7 +1013,7 @@ static inline void Vec_IntDrop( Vec_Int_t * p, int i )
static inline void Vec_IntInsert( Vec_Int_t * p, int iHere, int Entry )
{
int i;
assert( iHere >= 0 && iHere < p->nSize );
assert( iHere >= 0 && iHere <= p->nSize );
Vec_IntPush( p, 0 );
for ( i = p->nSize - 1; i > iHere; i-- )
p->pArray[i] = p->pArray[i-1];
......
......@@ -64,6 +64,8 @@ struct Vec_Ptr_t_
for ( i = Vec_PtrSize(vVec) - 1; (i >= 0) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i-- )
#define Vec_PtrForEachEntryTwo( Type1, vVec1, Type2, vVec2, pEntry1, pEntry2, i ) \
for ( i = 0; (i < Vec_PtrSize(vVec1)) && (((pEntry1) = (Type1)Vec_PtrEntry(vVec1, i)), 1) && (((pEntry2) = (Type2)Vec_PtrEntry(vVec2, i)), 1); i++ )
#define Vec_PtrForEachEntryDouble( Type1, Type2, vVec, Entry1, Entry2, i ) \
for ( i = 0; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = (Type1)Vec_PtrEntry(vVec, i)), 1) && (((Entry2) = (Type2)Vec_PtrEntry(vVec, i+1)), 1); i += 2 )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
......@@ -464,6 +466,14 @@ static inline void Vec_PtrFill( Vec_Ptr_t * p, int nSize, void * Entry )
p->pArray[i] = Entry;
p->nSize = nSize;
}
static inline void Vec_PtrFillTwo( Vec_Ptr_t * p, int nSize, void * EntryEven, void * EntryOdd )
{
int i;
Vec_PtrGrow( p, nSize );
for ( i = 0; i < nSize; i++ )
p->pArray[i] = (i & 1) ? EntryOdd : EntryEven;
p->nSize = nSize;
}
/**Function*************************************************************
......@@ -624,6 +634,11 @@ static inline void Vec_PtrPush( Vec_Ptr_t * p, void * Entry )
}
p->pArray[p->nSize++] = Entry;
}
static inline void Vec_PtrPushTwo( Vec_Ptr_t * p, void * Entry1, void * Entry2 )
{
Vec_PtrPush( p, Entry1 );
Vec_PtrPush( p, Entry2 );
}
/**Function*************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment