diff options
author | drh <> | 2023-07-11 19:54:17 +0000 |
---|---|---|
committer | drh <> | 2023-07-11 19:54:17 +0000 |
commit | 8a1104940d76c9c948cfdda5a61cf2e0aa8c3d04 (patch) | |
tree | bde13b808ee947231adb3a7ff84ed63cfe93a694 /src | |
parent | 4c40b7b819bed28a63a04eed32882ee46bc826fc (diff) | |
download | sqlite-8a1104940d76c9c948cfdda5a61cf2e0aa8c3d04.tar.gz sqlite-8a1104940d76c9c948cfdda5a61cf2e0aa8c3d04.zip |
Reduce divergence between branches: trunk and wal-shm-exceptions.
FossilOrigin-Name: d38ed6b1fc6b572997d520c36f256c11404fb1bd5f28acab07466bfc96554a8f
Diffstat (limited to 'src')
-rw-r--r-- | src/wal.c | 18 |
1 files changed, 4 insertions, 14 deletions
@@ -1818,23 +1818,15 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){ nByte = sizeof(WalIterator) + (nSegment-1)*sizeof(struct WalSegment) + iLast*sizeof(ht_slot); - p = (WalIterator *)sqlite3_malloc64(nByte); + p = (WalIterator *)sqlite3_malloc64(nByte + + sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast) + ); if( !p ){ return SQLITE_NOMEM_BKPT; } memset(p, 0, nByte); p->nSegment = nSegment; - - /* Allocate temporary space used by the merge-sort routine. This block - ** of memory will be freed before this function returns. - */ - aTmp = (ht_slot *)sqlite3_malloc64( - sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast) - ); - if( !aTmp ){ - rc = SQLITE_NOMEM_BKPT; - } - + aTmp = (ht_slot*)&(((u8*)p)[nByte]); for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){ WalHashLoc sLoc; @@ -1862,8 +1854,6 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){ p->aSegment[i].aPgno = (u32 *)sLoc.aPgno; } } - sqlite3_free(aTmp); - if( rc!=SQLITE_OK ){ walIteratorFree(p); p = 0; |