mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Update this branch with latest changes from wal2.
FossilOrigin-Name: 0ab899012cef8f32e1a4c9a47c54b73576f7fe3757e97353ccbc7fc87a4a1ea9
This commit is contained in:
@@ -1981,13 +1981,29 @@ int sqlite3session_attach(
|
||||
** If successful, return zero. Otherwise, if an OOM condition is encountered,
|
||||
** set *pRc to SQLITE_NOMEM and return non-zero.
|
||||
*/
|
||||
static int sessionBufferGrow(SessionBuffer *p, size_t nByte, int *pRc){
|
||||
if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){
|
||||
static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){
|
||||
#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1)
|
||||
i64 nReq = p->nBuf + nByte;
|
||||
if( *pRc==SQLITE_OK && nReq>p->nAlloc ){
|
||||
u8 *aNew;
|
||||
i64 nNew = p->nAlloc ? p->nAlloc : 128;
|
||||
|
||||
do {
|
||||
nNew = nNew*2;
|
||||
}while( (size_t)(nNew-p->nBuf)<nByte );
|
||||
}while( nNew<nReq );
|
||||
|
||||
/* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation
|
||||
** of sqlite3_realloc64(). Allocations greater than this size in bytes
|
||||
** always fail. It is used here to ensure that this routine can always
|
||||
** allocate up to this limit - instead of up to the largest power of
|
||||
** two smaller than the limit. */
|
||||
if( nNew>SESSION_MAX_BUFFER_SZ ){
|
||||
nNew = SESSION_MAX_BUFFER_SZ;
|
||||
if( nNew<nReq ){
|
||||
*pRc = SQLITE_NOMEM;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
|
||||
if( 0==aNew ){
|
||||
|
Reference in New Issue
Block a user