summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-08-26 14:30:42 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2015-08-26 14:30:42 -0700
commitcb439f2ecf000ebaab4447de120a95480b231ef5 (patch)
tree68a0b3a5df89ebaf5c22fc93cd1bcd33bfb1f785
parent41d18ca05113b33508cb67d10c2ec1fecfd4d4b2 (diff)
downloadabc-cb439f2ecf000ebaab4447de120a95480b231ef5.tar.gz
abc-cb439f2ecf000ebaab4447de120a95480b231ef5.tar.bz2
abc-cb439f2ecf000ebaab4447de120a95480b231ef5.zip
Bug fix in Vec_IntInsert() and a couple of new APIs.
-rw-r--r--src/base/cba/cbaPrs.h18
-rw-r--r--src/misc/vec/vecInt.h2
-rw-r--r--src/misc/vec/vecPtr.h15
3 files changed, 34 insertions, 1 deletions
diff --git a/src/base/cba/cbaPrs.h b/src/base/cba/cbaPrs.h
index cd0628e6..2f5220d3 100644
--- a/src/base/cba/cbaPrs.h
+++ b/src/base/cba/cbaPrs.h
@@ -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 )
{
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index 785b0aef..8ef1c364 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -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];
diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h
index 5fa40112..b700d221 100644
--- a/src/misc/vec/vecPtr.h
+++ b/src/misc/vec/vecPtr.h
@@ -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*************************************************************