aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2023-07-11 19:54:17 +0000
committerdrh <>2023-07-11 19:54:17 +0000
commit8a1104940d76c9c948cfdda5a61cf2e0aa8c3d04 (patch)
treebde13b808ee947231adb3a7ff84ed63cfe93a694 /src
parent4c40b7b819bed28a63a04eed32882ee46bc826fc (diff)
downloadsqlite-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.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/wal.c b/src/wal.c
index f4d0328b2..747cf099e 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -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;