aboutsummaryrefslogtreecommitdiff
path: root/src/flexbuf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/flexbuf.cpp')
-rw-r--r--src/flexbuf.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/flexbuf.cpp b/src/flexbuf.cpp
index acd55a7..6d55294 100644
--- a/src/flexbuf.cpp
+++ b/src/flexbuf.cpp
@@ -204,3 +204,26 @@ int FlexBuf::findChar( char cTarget )
204 return -1; 204 return -1;
205} 205}
206 206
207void FlexBuf::ensureCapacity( int nAmount )
208{
209 if( nLastChar + nAmount + 1 > nSize )
210 {
211 if( nFill + nAmount + 1 < nSize )
212 {
213 memcpy( lpBuf, lpBuf+nFirstChar, nFill );
214 nLastChar -= nFirstChar;
215 nFirstChar = 0;
216 }
217 else
218 {
219 nSize += nAmount+1;
220 char *lpNewBuf = new char[nSize];
221 memcpy( lpNewBuf, lpBuf+nFirstChar, nFill );
222 delete[] lpBuf;
223 lpBuf = lpNewBuf;
224 nLastChar -= nFirstChar;
225 nFirstChar = 0;
226 }
227 }
228}
229