]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add internal interfaces: PageMalloc/PageFree and ScratchMalloc/ScratchFree. (CVS...
authordrh <drh@noemail.net>
Tue, 17 Jun 2008 15:12:00 +0000 (15:12 +0000)
committerdrh <drh@noemail.net>
Tue, 17 Jun 2008 15:12:00 +0000 (15:12 +0000)
FossilOrigin-Name: 3e797d0ffe1af6f7512b3fb7b387418ac05671e0

manifest
manifest.uuid
src/btree.c
src/malloc.c
src/mem1.c
src/mem2.c
src/pager.c
src/sqlite.h.in
src/sqliteInt.h

index 7403b91af373136f25d9ed72387f25c14af74f10..06bfbcbf0d39992a6b732f016f6dec338e7b68d7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Do\snot\sallow\sa\sVACUUM\sto\stry\sto\schange\sthe\spage_size\son\san\sencrypted\sdatabase.\s(CVS\s5225)
-D 2008-06-17T01:03:26
+C Add\sinternal\sinterfaces:\s\sPageMalloc/PageFree\sand\sScratchMalloc/ScratchFree.\s(CVS\s5226)
+D 2008-06-17T15:12:01
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in dc5608df93faf4406cfd7a1c8ed9ab93d8bfbfd5
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -96,7 +96,7 @@ F src/attach.c b18ba42c77f7d3941f5d23d2ca20fa1d841a4e91
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
 F src/bitvec.c ab50c4b8c6a899dae499f5a805eebe4223c78269
 F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
-F src/btree.c b374c2ba457f442371aa92b065d1ba698cdee1dc
+F src/btree.c a7b1ffdde06b8e854076789e393b315ee7856ae5
 F src/btree.h b1bd7e0b8c2e33658aaf447cb0d1d94f74664b6b
 F src/btreeInt.h 02325f04758dba0fcd0c08ac55cd9b189dad61a5
 F src/build.c 88cc5501a87f72d0538b040001d88d31f994edea
@@ -116,10 +116,10 @@ F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
 F src/legacy.c 3626c71fb70912abec9a4312beba753a9ce800df
 F src/loadext.c f99a75534a53e281fa2461239ee4a4b4bf6ad564
 F src/main.c 1f65b285a87f237e9e63c9628f220d10aef36b81
-F src/malloc.c c5bdf8967df9acc9765ed1b55c0c0eba9fe9494c
+F src/malloc.c 7b622d22f29e3be56d271a5a921f3b5788330189
 F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
-F src/mem1.c c8e07e9e6620b1aabf9bdefd19dee93831f67733
-F src/mem2.c 53d29d8275753e05676536c5db8f4867a622b31c
+F src/mem1.c 159f10e280f2d9aea597cf938851e61652dd5c3d
+F src/mem2.c 809d0e311c38521779e92262f51bd847d12d0f4d
 F src/mem3.c 617c2e2a72a10ecc5c01af14efc8c2596d2c2e87
 F src/mem4.c 45c328ec6dcb7e8d319cb383615b5fe547ca5409
 F src/mem5.c 3d2ff00c6e3bc37f5d82cd82e1a123b246fb7b39
@@ -134,7 +134,7 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
 F src/os_os2.c 9f74147f1899793a106827f6bc770363ec377912
 F src/os_unix.c dd4a7b19ec00869764c389560c3faf566cf98a71
 F src/os_win.c 0b90d9a1ce18bfd2a5f3c4a6bdb13ec369c805a9
-F src/pager.c 5599fb3ebb63a60ecb44a18a594b371484a7e128
+F src/pager.c 124b3eaed1bcf9d19b183b5796fa94e292f8cdb8
 F src/pager.h 6aa3050a3c684475a5a9dbad5ff1cebad612acba
 F src/parse.y 8c2c3145eebe1964eb279cb3c4e502eae28bb0fa
 F src/pragma.c 70e7c865dce85fdf9df81848af2169009a56ed08
@@ -143,9 +143,9 @@ F src/printf.c 8b063da9dcde26b7c500a01444b718d86f21bc6e
 F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
 F src/select.c 669687459e7d0193c89de06c5dbed55b4a41191c
 F src/shell.c a12ea645271b7876c8f080146f48e20b00d367ec
-F src/sqlite.h.in 9ff44542f18937a987f13dbc64f29f9a93b8b521
+F src/sqlite.h.in 1444cdd69bd9377fe33fd273a4554b75fb0b5ede
 F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
-F src/sqliteInt.h bf561dab8a5155f25d3415fa056f570a731e2792
+F src/sqliteInt.h e579f90f7d070f604f79bb85029c424d273cc20b
 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
 F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
 F src/tclsqlite.c c57e740e30bd6dda678796eed62c7f0e64689834
@@ -594,7 +594,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P bb4edb53964559fc1cd69700beb72ecc29b58f37
-R 7166a804863eb0c7dec5311dc0bfcdb3
+P d49e5020019093a5b8a4fbe09caeb84ecb538629
+R 25fbb9097db5d9ffe1b1d6302c5755df
 U drh
-Z 9f8da086219df1d3431408cc19590d26
+Z e3fe71a0b1fa8d45526d8e8aaa39339c
index acdcace9cbd50b110284a2baf0bf029c32af9f16..9ddef60bb463704aa96d4a61f8a38753354a8bda 100644 (file)
@@ -1 +1 @@
-d49e5020019093a5b8a4fbe09caeb84ecb538629
\ No newline at end of file
+3e797d0ffe1af6f7512b3fb7b387418ac05671e0
\ No newline at end of file
index 1140e7756a19c756d8d00d9183ae2fcdd88812af..be003249c0465010c6008df2f466b5bf67d94af4 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.464 2008/06/15 02:51:47 drh Exp $
+** $Id: btree.c,v 1.465 2008/06/17 15:12:01 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -3719,14 +3719,14 @@ int sqlite3BtreeMoveto(
         if( available>=nCellKey ){
           c = sqlite3VdbeRecordCompare(nCellKey, pCellKey, pUnKey);
         }else{
-          pCellKey = sqlite3TempMalloc( nCellKey );
+          pCellKey = sqlite3Malloc( nCellKey );
           if( pCellKey==0 ){
             rc = SQLITE_NOMEM;
             goto moveto_finish;
           }
           rc = sqlite3BtreeKey(pCur, 0, nCellKey, (void *)pCellKey);
           c = sqlite3VdbeRecordCompare(nCellKey, pCellKey, pUnKey);
-          sqlite3TempFree(pCellKey);
+          sqlite3_free(pCellKey);
           if( rc ) goto moveto_finish;
         }
       }
@@ -4860,6 +4860,7 @@ static int balance_nonroot(MemPage *pPage){
   int subtotal;                /* Subtotal of bytes in cells on one page */
   int iSpace1 = 0;             /* First unused byte of aSpace1[] */
   int iSpace2 = 0;             /* First unused byte of aSpace2[] */
+  int szScratch;               /* Size of scratch memory requested */
   MemPage *apOld[NB];          /* pPage and up to two siblings */
   Pgno pgnoOld[NB];            /* Page numbers for each page in apOld[] */
   MemPage *apCopy[NB];         /* Private copies of apOld[] pages */
@@ -4990,13 +4991,13 @@ static int balance_nonroot(MemPage *pPage){
   /*
   ** Allocate space for memory structures
   */
-  apCell = sqlite3TempMalloc( 
+  szScratch =
        nMaxCells*sizeof(u8*)                       /* apCell */
      + nMaxCells*sizeof(u16)                       /* szCell */
      + (ROUND8(sizeof(MemPage))+pBt->pageSize)*NB  /* aCopy */
      + pBt->pageSize                               /* aSpace1 */
-     + (ISAUTOVACUUM ? nMaxCells : 0)              /* aFrom */
-  );
+     + (ISAUTOVACUUM ? nMaxCells : 0);             /* aFrom */
+  apCell = sqlite3ScratchMalloc( szScratch ); 
   if( apCell==0 ){
     rc = SQLITE_NOMEM;
     goto balance_cleanup;
@@ -5015,7 +5016,7 @@ static int balance_nonroot(MemPage *pPage){
     aFrom = &aSpace1[pBt->pageSize];
   }
 #endif
-  aSpace2 = sqlite3Malloc(pBt->pageSize);
+  aSpace2 = sqlite3PageMalloc(pBt->pageSize);
   if( aSpace2==0 ){
     rc = SQLITE_NOMEM;
     goto balance_cleanup;
@@ -5397,7 +5398,7 @@ static int balance_nonroot(MemPage *pPage){
   ** But the parent page will always be initialized.
   */
   assert( pParent->isInit );
-  sqlite3TempFree(apCell);
+  sqlite3ScratchFree(apCell);
   apCell = 0;
   rc = balance(pParent, 0);
   
@@ -5405,8 +5406,8 @@ static int balance_nonroot(MemPage *pPage){
   ** Cleanup before returning.
   */
 balance_cleanup:
-  sqlite3_free(aSpace2);
-  sqlite3TempFree(apCell);
+  sqlite3PageFree(aSpace2);
+  sqlite3ScratchFree(apCell);
   for(i=0; i<nOld; i++){
     releasePage(apOld[i]);
   }
index 3c567c9c0da132c439b78ded0f557eb1c11e6581..7db0eacc39d23c388947dec5a5c870796f2c8ee7 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** Memory allocation functions used throughout sqlite.
 **
-** $Id: malloc.c,v 1.17 2008/06/15 02:51:48 drh Exp $
+** $Id: malloc.c,v 1.18 2008/06/17 15:12:01 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -91,7 +91,7 @@ static struct {
   sqlite3_int64 nowUsed;  /* Main memory currently in use */
   sqlite3_int64 mxUsed;   /* Highwater mark for nowUsed */
   int mxReq;              /* Max request size for ordinary mallocs */
-  int mxTempReq;          /* Max request size for xTemp mallocs */
+  int mxScratchReq;       /* Max request size for xTemp mallocs */
 } mem0;
 
 /*
@@ -229,12 +229,12 @@ void *sqlite3_malloc(int n){
 
 /*
 ** Each thread may only have a single outstanding allocation from
-** xTempMalloc().  We verify this constraint in the single-threaded
-** case by setting tempAllocOut to 1 when an allocation
+** xScratchMalloc().  We verify this constraint in the single-threaded
+** case by setting scratchAllocOut to 1 when an allocation
 ** is outstanding clearing it when the allocation is freed.
 */
 #if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
-static int tempAllocOut = 0;
+static int scratchAllocOut = 0;
 #endif
 
 
@@ -246,36 +246,46 @@ static int tempAllocOut = 0;
 ** structures that would not normally fit on the stack of an
 ** embedded processor.
 */
-void *sqlite3TempMalloc(int n){
+void *sqlite3ScratchMalloc(int n){
   void *p;
   assert( n>0 );
   if( sqlite3FaultStep(SQLITE_FAULTINJECTOR_MALLOC) ){
     return 0;
   }
 #if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
-  assert( tempAllocOut==0 );
-  tempAllocOut = 1;
+  assert( scratchAllocOut==0 );
+  scratchAllocOut = 1;
 #endif
   if( sqlite3Config.bMemstat ){
     sqlite3_mutex_enter(mem0.mutex);
-    if( n>mem0.mxTempReq ) mem0.mxTempReq = n;
-    p = sqlite3Config.m.xTempMalloc(n);
+    if( n>mem0.mxScratchReq ) mem0.mxScratchReq = n;
+    p = sqlite3Config.m.xMalloc(n);
     sqlite3_mutex_leave(mem0.mutex);
   }else{
-    p = sqlite3Config.m.xTempMalloc(n);
+    p = sqlite3Config.m.xMalloc(n);
   }
   return p;
 }
-void sqlite3TempFree(void *p){
+void sqlite3ScratchFree(void *p){
   if( p ){
 #if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
-    assert( tempAllocOut==1 );
-    tempAllocOut = 0;
+    assert( scratchAllocOut==1 );
+    scratchAllocOut = 0;
 #endif
-    sqlite3Config.m.xTempFree(p);
+    sqlite3Config.m.xFree(p);
   }
 }
 
+/*
+** Place holders for the page-cache memory allocator.
+*/
+void *sqlite3PageMalloc(int iSize){
+  return sqlite3Malloc(iSize);
+}
+void sqlite3PageFree(void *pOld){
+  sqlite3_free(pOld);
+}
+
 /*
 ** Return the size of a memory allocation previously obtained from
 ** sqlite3Malloc() or sqlite3_malloc().
index 120fc040ca971dd923104dc8162d074257e12aa2..e423225389ba53905c7b996c6ade330e8ce1aecd 100644 (file)
@@ -17,7 +17,7 @@
 ** This file contains implementations of the low-level memory allocation
 ** routines specified in the sqlite3_mem_methods object.
 **
-** $Id: mem1.c,v 1.20 2008/06/15 02:51:48 drh Exp $
+** $Id: mem1.c,v 1.21 2008/06/17 15:12:01 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -130,8 +130,6 @@ void sqlite3MemSetDefault(void){
      sqlite3MemRealloc,
      sqlite3MemSize,
      sqlite3MemRoundup,
-     sqlite3MemMalloc,
-     sqlite3MemFree,
      sqlite3MemInit,
      sqlite3MemShutdown,
      0
index ffc31987cc9f145036797082f6a6fb2454c70fa6..311f02dbdbd67be23f2e23b5d4377ff2665e2f40 100644 (file)
@@ -19,7 +19,7 @@
 ** This file contains implementations of the low-level memory allocation
 ** routines specified in the sqlite3_mem_methods object.
 **
-** $Id: mem2.c,v 1.29 2008/06/15 02:51:48 drh Exp $
+** $Id: mem2.c,v 1.30 2008/06/17 15:12:01 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -312,8 +312,6 @@ void sqlite3MemSetDefault(void){
      sqlite3MemRealloc,
      sqlite3MemSize,
      sqlite3MemRoundup,
-     sqlite3MemMalloc,
-     sqlite3MemFree,
      sqlite3MemInit,
      sqlite3MemShutdown,
      0
index 5dab5a41de41c95395dddc472e25a240bbbb55dc..b1e08e848af8e8c3a62f0754e477cd6d2b33b23b 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.457 2008/06/15 02:51:48 drh Exp $
+** @(#) $Id: pager.c,v 1.458 2008/06/17 15:12:01 drh Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -773,19 +773,20 @@ static int osUnlock(sqlite3_file *pFd, int eLock){
 static int jrnlBufferSize(Pager *pPager){
   int dc;           /* Device characteristics */
   int nSector;      /* Sector size */
-  int nPage;        /* Page size */
+  int szPage;        /* Page size */
   sqlite3_file *fd = pPager->fd;
 
   if( fd->pMethods ){
     dc = sqlite3OsDeviceCharacteristics(fd);
     nSector = sqlite3OsSectorSize(fd);
-    nPage = pPager->pageSize;
+    szPage = pPager->pageSize;
   }
 
   assert(SQLITE_IOCAP_ATOMIC512==(512>>8));
   assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));
 
-  if( !fd->pMethods || (dc&(SQLITE_IOCAP_ATOMIC|(nPage>>8))&&nSector<=nPage) ){
+  if( !fd->pMethods || 
+       (dc & (SQLITE_IOCAP_ATOMIC|(szPage>>8)) && nSector<=szPage) ){
     return JOURNAL_HDR_SZ(pPager) + JOURNAL_PG_SZ(pPager);
   }
   return 0;
@@ -1294,7 +1295,7 @@ static void pager_reset(Pager *pPager){
     PAGER_INCR(sqlite3_pager_pgfree_count);
     pNext = pPg->pNextAll;
     lruListRemove(pPg);
-    sqlite3_free(pPg->pData);
+    sqlite3PageFree(pPg->pData);
     sqlite3_free(pPg);
   }
   assert(pPager->lru.pFirst==0);
@@ -2180,7 +2181,7 @@ int sqlite3PagerOpen(
   int useJournal = (flags & PAGER_OMIT_JOURNAL)==0;
   int noReadlock = (flags & PAGER_NO_READLOCK)!=0;
   int journalFileSize = sqlite3JournalSize(pVfs);
-  int nDefaultPage = SQLITE_DEFAULT_PAGE_SIZE;
+  int szPageDflt = SQLITE_DEFAULT_PAGE_SIZE;
   char *zPathname = 0;
   int nPathname = 0;
 
@@ -2259,8 +2260,8 @@ int sqlite3PagerOpen(
       */
       if( rc==SQLITE_OK && !readOnly ){
         int iSectorSize = sqlite3OsSectorSize(pPager->fd);
-        if( nDefaultPage<iSectorSize ){
-          nDefaultPage = iSectorSize;
+        if( szPageDflt<iSectorSize ){
+          szPageDflt = iSectorSize;
         }
 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
         {
@@ -2269,13 +2270,13 @@ int sqlite3PagerOpen(
           assert(SQLITE_IOCAP_ATOMIC512==(512>>8));
           assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));
           assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);
-          for(ii=nDefaultPage; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){
-            if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ) nDefaultPage = ii;
+          for(ii=szPageDflt; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){
+            if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ) szPageDflt = ii;
           }
         }
 #endif
-        if( nDefaultPage>SQLITE_MAX_DEFAULT_PAGE_SIZE ){
-          nDefaultPage = SQLITE_MAX_DEFAULT_PAGE_SIZE;
+        if( szPageDflt>SQLITE_MAX_DEFAULT_PAGE_SIZE ){
+          szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE;
         }
       }
     }
@@ -2289,7 +2290,7 @@ int sqlite3PagerOpen(
   }
 
   if( pPager && rc==SQLITE_OK ){
-    pPager->pTmpSpace = sqlite3MallocZero(nDefaultPage);
+    pPager->pTmpSpace = sqlite3PageMalloc(szPageDflt);
   }
 
   /* If an error occured in either of the blocks above.
@@ -2326,7 +2327,7 @@ int sqlite3PagerOpen(
   /* pPager->stmtInUse = 0; */
   /* pPager->nRef = 0; */
   pPager->dbSize = memDb-1;
-  pPager->pageSize = nDefaultPage;
+  pPager->pageSize = szPageDflt;
   /* pPager->stmtSize = 0; */
   /* pPager->stmtJSize = 0; */
   /* pPager->nPage = 0; */
@@ -2421,7 +2422,7 @@ int sqlite3PagerSetPagesize(Pager *pPager, u16 *pPageSize){
   if( pageSize && pageSize!=pPager->pageSize 
    && !pPager->memDb && pPager->nRef==0 
   ){
-    char *pNew = (char *)sqlite3Malloc(pageSize);
+    char *pNew = (char *)sqlite3PageMalloc(pageSize);
     if( !pNew ){
       rc = SQLITE_NOMEM;
     }else{
@@ -2429,7 +2430,7 @@ int sqlite3PagerSetPagesize(Pager *pPager, u16 *pPageSize){
       pager_reset(pPager);
       pPager->pageSize = pageSize;
       setSectorSize(pPager);
-      sqlite3_free(pPager->pTmpSpace);
+      sqlite3PageFree(pPager->pTmpSpace);
       pPager->pTmpSpace = pNew;
       pagerLeave(pPager);
     }
@@ -2567,8 +2568,8 @@ int sqlite3PagerPagecount(Pager *pPager, int *pnPage){
 ** Clear a PgHistory block
 */
 static void clearHistory(PgHistory *pHist){
-  sqlite3_free(pHist->pOrig);
-  sqlite3_free(pHist->pStmt);
+  sqlite3PageFree(pHist->pOrig);
+  sqlite3PageFree(pHist->pStmt);
   pHist->pOrig = 0;
   pHist->pStmt = 0;
 }
@@ -2653,7 +2654,7 @@ static void pager_truncate_cache(Pager *pPager){
       PAGER_INCR(sqlite3_pager_pgfree_count);
       unlinkPage(pPg);
       makeClean(pPg);
-      sqlite3_free(pPg->pData);
+      sqlite3PageFree(pPg->pData);
       sqlite3_free(pPg);
       pPager->nPage--;
     }
@@ -2790,7 +2791,7 @@ int sqlite3PagerClose(Pager *pPager){
   */
 
   sqlite3_free(pPager->aHash);
-  sqlite3_free(pPager->pTmpSpace);
+  sqlite3PageFree(pPager->pTmpSpace);
   sqlite3_free(pPager);
   return SQLITE_OK;
 }
@@ -3347,7 +3348,7 @@ int sqlite3PagerReleaseMemory(int nReq){
       );
       IOTRACE(("PGFREE %p %d *\n", pPager, pPg->pgno));
       PAGER_INCR(sqlite3_pager_pgfree_count);
-      sqlite3_free(pPg->pData);
+      sqlite3PageFree(pPg->pData);
       sqlite3_free(pPg);
       pPager->nPage--;
     }else{
@@ -3649,7 +3650,7 @@ static int pagerAllocatePage(Pager *pPager, PgHdr **ppPg){
               + MEMDB*sizeof(PgHistory);
     pPg = sqlite3Malloc( nByteHdr );
     if( pPg ){
-      pData = sqlite3Malloc( pPager->pageSize );
+      pData = sqlite3PageMalloc( pPager->pageSize );
       if( pData==0 ){
         sqlite3_free(pPg);
         pPg = 0;
@@ -4223,7 +4224,7 @@ static int pager_write(PgHdr *pPg){
           PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager);
           PAGERTRACE3("JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
           assert( pHist->pOrig==0 );
-          pHist->pOrig = sqlite3Malloc( pPager->pageSize );
+          pHist->pOrig = sqlite3PageMalloc( pPager->pageSize );
           if( !pHist->pOrig ){
             return SQLITE_NOMEM;
           }
@@ -4293,7 +4294,7 @@ static int pager_write(PgHdr *pPg){
       if( MEMDB ){
         PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager);
         assert( pHist->pStmt==0 );
-        pHist->pStmt = sqlite3Malloc( pPager->pageSize );
+        pHist->pStmt = sqlite3PageMalloc( pPager->pageSize );
         if( pHist->pStmt ){
           memcpy(pHist->pStmt, PGHDR_TO_DATA(pPg), pPager->pageSize);
         }
@@ -5035,7 +5036,7 @@ int sqlite3PagerStmtCommit(Pager *pPager){
         assert( pHist->inStmt );
         pHist->inStmt = 0;
         pHist->pPrevStmt = pHist->pNextStmt = 0;
-        sqlite3_free(pHist->pStmt);
+        sqlite3PageFree(pHist->pStmt);
         pHist->pStmt = 0;
       }
     }
@@ -5063,7 +5064,7 @@ int sqlite3PagerStmtRollback(Pager *pPager){
         pHist = PGHDR_TO_HIST(pPg, pPager);
         if( pHist->pStmt ){
           memcpy(PGHDR_TO_DATA(pPg), pHist->pStmt, pPager->pageSize);
-          sqlite3_free(pHist->pStmt);
+          sqlite3PageFree(pHist->pStmt);
           pHist->pStmt = 0;
         }
       }
index ca26f2c710b9e313be0afde2ba3dfa0caffa9072..52e7f55376e421ae869854610be33209b7c776a1 100644 (file)
@@ -30,7 +30,7 @@
 ** the version number) and changes its name to "sqlite3.h" as
 ** part of the build process.
 **
-** @(#) $Id: sqlite.h.in,v 1.328 2008/06/15 02:51:48 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.329 2008/06/17 15:12:01 drh Exp $
 */
 #ifndef _SQLITE3_H_
 #define _SQLITE3_H_
@@ -975,15 +975,7 @@ int sqlite3_config(int, ...);
 ** The xRoundup method returns what would be the allocated size of
 ** a memory allocation given a particular requested size.  Most memory
 ** allocators round up memory allocations at least to the next multiple
-** of 8.  Some round up to a larger multiple or to a power of 2. 
-**
-** The xTempMalloc and xTempFree methods are used to allocate a large
-** chunk of temporary-use memory whose lifetime is a single procedure
-** call.  These routines may be the same as xMalloc and xFree, if desired,
-** though some specialized applications may benefit from using a different
-** allocation algorithm in this case. 
-** SQLite will never request more than one outstanding memory allocation
-** per thread using xTempMalloc.
+** of 8.  Some allocators round up to a larger multiple or to a power of 2. 
 **
 ** The xInit method initializes the memory allocator.  (For example,
 ** it might allocate any require mutexes or initialize internal data
@@ -999,8 +991,6 @@ struct sqlite3_mem_methods {
   void *(*xRealloc)(void*,int);  /* Resize an allocation */
   int (*xSize)(void*);           /* Return the size of an allocation */
   int (*xRoundup)(int);          /* Round up request size to allocation size */
-  void *(*xTempMalloc)(int);     /* Allocate temporary space */
-  void (*xTempFree)(void*);      /* Free space from xTempMalloc */
   int (*xInit)(void*);           /* Initialize the memory allocator */
   void (*xShutdown)(void*);      /* Deinitialize the memory allocator */
   void *pAppData;                /* Argument to xInit() and xShutdown() */
index cccc29e771bc829b3104b7c6bb2c66ef0d8c5e38..e0b9c4c05a5f847f026d5de15ecfecccaf7c89c2 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.710 2008/06/15 02:51:48 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.711 2008/06/17 15:12:01 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -1791,8 +1791,10 @@ void *sqlite3Realloc(void*, int);
 void *sqlite3DbReallocOrFree(sqlite3 *, void *, int);
 void *sqlite3DbRealloc(sqlite3 *, void *, int);
 int sqlite3MallocSize(void *);
-void *sqlite3TempMalloc(int);
-void sqlite3TempFree(void*);
+void *sqlite3ScratchMalloc(int);
+void sqlite3ScratchFree(void*);
+void *sqlite3PageMalloc(int);
+void sqlite3PageFree(void*);
 void sqlite3MemSetDefault(void);
 
 int sqlite3IsNaN(double);