1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Use exponential buffer size growth in StrAccum, as long as the size does not

grow to large, to avoid excess memory allocation resize operations.  Also,
document the fact that setting scratch memory causes SQLite to try to avoid
large memory allocations.

FossilOrigin-Name: a518bc3318232d652349eb29303ff250aee40459
This commit is contained in:
drh
2014-11-03 14:46:29 +00:00
parent 7f5a7ecd21
commit 7b4d780b54
5 changed files with 25 additions and 17 deletions

View File

@@ -770,6 +770,11 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
char *zOld = (p->zText==p->zBase ? 0 : p->zText);
i64 szNew = p->nChar;
szNew += N + 1;
if( szNew+p->nChar<=p->mxAlloc ){
/* Force exponential buffer size growth as long as it does not overflow,
** to avoid having to call this routine too often */
szNew += p->nChar;
}
if( szNew > p->mxAlloc ){
sqlite3StrAccumReset(p);
setStrAccumError(p, STRACCUM_TOOBIG);