aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2007-10-20 13:17:54 +0000
committerdrh <drh@noemail.net>2007-10-20 13:17:54 +0000
commit1e3af3343665cdf5a741e8d79d19d3599edea00b (patch)
treef5e14e9b56b87d8382473c9f98212546025b83b7 /src
parent80ca2d09356d7ae867c4e8f0a4defd25a6121643 (diff)
downloadsqlite-1e3af3343665cdf5a741e8d79d19d3599edea00b.tar.gz
sqlite-1e3af3343665cdf5a741e8d79d19d3599edea00b.zip
Go back to allocating each page and its header with a single memory
allocation. This undoes the change of (4409). (CVS 4495) FossilOrigin-Name: f56c9884be796dee3f267aca6021eb1846d8527c
Diffstat (limited to 'src')
-rw-r--r--src/pager.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/pager.c b/src/pager.c
index b0ad7158b..9e3163d0f 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.392 2007/10/03 15:22:26 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.393 2007/10/20 13:17:55 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -1227,7 +1227,6 @@ static void pager_reset(Pager *pPager){
PAGER_INCR(sqlite3_pager_pgfree_count);
pNext = pPg->pNextAll;
lruListRemove(pPg);
- sqlite3_free(pPg->pData);
sqlite3_free(pPg);
}
assert(pPager->lru.pFirst==0);
@@ -2533,7 +2532,6 @@ static void pager_truncate_cache(Pager *pPager){
PAGER_INCR(sqlite3_pager_pgfree_count);
unlinkPage(pPg);
makeClean(pPg);
- sqlite3_free(pPg->pData);
sqlite3_free(pPg);
pPager->nPage--;
}
@@ -3197,7 +3195,6 @@ int sqlite3PagerReleaseMemory(int nReq){
);
IOTRACE(("PGFREE %p %d *\n", pPager, pPg->pgno));
PAGER_INCR(sqlite3_pager_pgfree_count);
- sqlite3_free(pPg->pData);
sqlite3_free(pPg);
pPager->nPage--;
}else{
@@ -3460,7 +3457,7 @@ static int pagerSharedLock(Pager *pPager){
static int pagerAllocatePage(Pager *pPager, PgHdr **ppPg){
int rc = SQLITE_OK;
PgHdr *pPg;
- void *pData;
+ int nByteHdr;
/* Create a new PgHdr if any of the four conditions defined
** above are met: */
@@ -3478,25 +3475,16 @@ static int pagerAllocatePage(Pager *pPager, PgHdr **ppPg){
}
}
pagerLeave(pPager);
- pPg = sqlite3_malloc( sizeof(*pPg) + sizeof(u32) + pPager->nExtra
- + MEMDB*sizeof(PgHistory) );
- if( pPg ){
- pData = sqlite3_malloc( pPager->pageSize );
- if( pData==0 ){
- sqlite3_free(pPg);
- pPg = 0;
- }
- }
+ nByteHdr = sizeof(*pPg) + sizeof(u32) + pPager->nExtra
+ + MEMDB*sizeof(PgHistory);
+ pPg = sqlite3_malloc( nByteHdr + pPager->pageSize );
pagerEnter(pPager);
if( pPg==0 ){
rc = SQLITE_NOMEM;
goto pager_allocate_out;
}
- memset(pPg, 0, sizeof(*pPg));
- if( MEMDB ){
- memset(PGHDR_TO_HIST(pPg, pPager), 0, sizeof(PgHistory));
- }
- pPg->pData = pData;
+ memset(pPg, 0, nByteHdr);
+ pPg->pData = (void*)(nByteHdr + (char*)pPg);
pPg->pPager = pPager;
pPg->pNextAll = pPager->pAll;
pPager->pAll = pPg;