summaryrefslogtreecommitdiffstats
path: root/src/misc/vec
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-08-08 18:47:42 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2015-08-08 18:47:42 -0700
commit356217eff7416606ebbcf739dbd999ba6b2db299 (patch)
tree7eca8f0b3f3cfcc39755a5785c3f17c9efe86689 /src/misc/vec
parentf039799b75735e62c82fb9e6aae6bf9aabec3063 (diff)
downloadabc-356217eff7416606ebbcf739dbd999ba6b2db299.tar.gz
abc-356217eff7416606ebbcf739dbd999ba6b2db299.tar.bz2
abc-356217eff7416606ebbcf739dbd999ba6b2db299.zip
Improvements to Cba data-structure.
Diffstat (limited to 'src/misc/vec')
-rw-r--r--src/misc/vec/vecStr.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h
index 63be43d5..04cd5da8 100644
--- a/src/misc/vec/vecStr.h
+++ b/src/misc/vec/vecStr.h
@@ -283,6 +283,10 @@ static inline char * Vec_StrArray( Vec_Str_t * p )
{
return p->pArray;
}
+static inline char * Vec_StrLimit( Vec_Str_t * p )
+{
+ return p->pArray + p->nSize;
+}
/**Function*************************************************************
@@ -299,6 +303,10 @@ static inline int Vec_StrSize( Vec_Str_t * p )
{
return p->nSize;
}
+static inline void Vec_StrSetSize( Vec_Str_t * p, int nSize )
+{
+ p->nSize = nSize;
+}
/**Function*************************************************************
@@ -668,6 +676,39 @@ static inline void Vec_StrPrintStr( Vec_Str_t * p, const char * pStr )
Vec_StrPush( p, pStr[i] );
}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+#ifdef WIN32
+#define vsnprintf _vsnprintf
+#endif
+
+static inline char * Vec_StrPrintF( Vec_Str_t * p, const char * format, ... )
+{
+ int nAdded, nSize = 1000;
+ va_list args; va_start( args, format );
+ Vec_StrGrow( p, Vec_StrSize(p) + nSize );
+ nAdded = vsnprintf( Vec_StrLimit(p), nSize, format, args );
+ if ( nAdded > nSize )
+ {
+ Vec_StrGrow( p, Vec_StrSize(p) + nAdded + nSize );
+ nSize = vsnprintf( Vec_StrLimit(p), nAdded, format, args );
+ assert( nSize == nAdded );
+ }
+ p->nSize += nAdded;
+ va_end( args );
+ return Vec_StrLimit(p) - nAdded;
+}
+
/**Function*************************************************************
Synopsis [Appends the string to the char vector.]