From: danielk1977 Date: Wed, 25 Jun 2008 14:26:07 +0000 (+0000) Subject: Fix the allocator in mem5.c so that it can be enabled at run time using the sqlite3_c... X-Git-Tag: version-3.6.10~873 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c66c0e14a69504fecfe19cfd0e031e94c1b0b1e3;p=thirdparty%2Fsqlite.git Fix the allocator in mem5.c so that it can be enabled at run time using the sqlite3_config() function. (CVS 5304) FossilOrigin-Name: 30ff6bb0b2d1068d28e86ac90bb9f454e4537a2d --- diff --git a/manifest b/manifest index d6690fd609..6bfbfa920f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sup\ssome\sdetails\sto\sdo\swith\sthe\smem3.c\s(memsys3)\sallocator.\sIf\sthe\slibrary\sis\scompiled\swith\sSQLITE_ENABLE_MEMSYS3,\sthe\smemsys3\sallocator\scan\sbe\sselected\sat\sruntime.\s(CVS\s5303) -D 2008-06-25T10:34:35 +C Fix\sthe\sallocator\sin\smem5.c\sso\sthat\sit\scan\sbe\senabled\sat\srun\stime\susing\sthe\ssqlite3_config()\sfunction.\s(CVS\s5304) +D 2008-06-25T14:26:08 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in ff6f90048555a0088f6a4b7406bed5e55a7c4eff F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -114,14 +114,14 @@ F src/insert.c f8c7da31409ec19a769b960a4a2b9cca7bab80bd F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e F src/legacy.c 3626c71fb70912abec9a4312beba753a9ce800df F src/loadext.c 40024a0f476c1279494876b9a002001b29e5d3e3 -F src/main.c 5ddfc15bdc034253bdb204522f77f2548d01f2c6 +F src/main.c 1291a974ff9ffcb771ce4060795c9c3059268049 F src/malloc.c f52166df8abd7ff6990dbee1a0ce3534addc8617 F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a F src/mem1.c 8340fa5f969e9f9b9bdeb54106457a2003456d2b F src/mem2.c 23f9538f35fbcd5665afe7056a56be0c7ed65aa7 F src/mem3.c 8ecfb0a61a363f34922fe3f73e698adf229eb55a F src/mem4.c 6703adb1717b26d9d70a1c2586b4b7b7ffee7909 -F src/mem5.c ad31a0a481b86b86f4ac0b6d952e69727d4e113a +F src/mem5.c 604b5989eb11bee83f4114208f8d6df0ebbe50df F src/mutex.c a485a0eac8ee2cd95f66e565b4c6696c18db968f F src/mutex.h 236677b27760d85701b5872d01b5cafedde5f0a9 F src/mutex_os2.c 9c5637aa4c307c552566d0f0b3bd206245b54a97 @@ -142,9 +142,9 @@ F src/printf.c 8b063da9dcde26b7c500a01444b718d86f21bc6e F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a F src/select.c 79f60dc4a7e90bb907c7a2cca42f45276d1ead99 F src/shell.c 61fa61932ed52825720ebfd3f8381b8d550ef766 -F src/sqlite.h.in 3ad63197bdc9fa1623c1e139ee6f39e7d2ccfa5b +F src/sqlite.h.in b5c731b88ab1275396920103b5ecbefba200d423 F src/sqlite3ext.h f162a72daef5ebf8b211fe8c0ec96e85d22fbf9b -F src/sqliteInt.h 5f0b40ff6924972923b7921cd36731ed292cf4da +F src/sqliteInt.h d045d18b412345ed2f9d2e5a05e6de25051522a5 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8 F src/status.c 6cb10377992505bd69f1ca1d75c1240a65f25a58 F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822 @@ -166,7 +166,7 @@ F src/test_devsym.c 6012cb8e3acf812513511025a4fa5d626e0ba19b F src/test_func.c f4aafa10f17d52c43a64b47717265802e6e552b3 F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f F src/test_loadext.c df8ab3a6481ddebbdf0d28ebac5d9e0790f7860f -F src/test_malloc.c 9cb0a261b2e744c1daf0ed407501eb6506ce9f75 +F src/test_malloc.c db4b54a81e83c0e71e1780365e022ed96fac52b0 F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071 F src/test_mutex.c b1433eb96520656fb3e4a218253a94ac32bd5775 F src/test_onefile.c 1f87d4a21cbfb24a7c35e4333fa0bd34d641f68d @@ -422,7 +422,7 @@ F test/pager2.test c025f91b75fe65e85febda64d9416428b8a5cab5 F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4 F test/pageropt.test 6df72c441db0a037b7ec6990d16311c24fbea77b F test/pagesize.test e0a8b3fe80f8b8e808d94a00734c7a18c76c407e -F test/permutations.test 501db15728957fa7893117c167f37cc7f1bb9387 +F test/permutations.test 23b6ff4ef5f8f1b78d9eb47fda8f8ad080757f49 F test/pragma.test 44bc52afa72cabfeae82641e0033ca24919f3ce8 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test c3405535b418d454e8a52196a0fc592ec9eec58d @@ -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 9902be8d66453d3f4cfdc7f81a4ebe9bc6729204 -R 1a2b1623ff42cc1c532b2d95d3c3b31f +P 9c6c8e01b31abfe2bc8e650bbfdb504021dc7e59 +R 8f7483e2fdaf9f81d7806dda44fbca72 U danielk1977 -Z 75609bc694f005e3e95998b63bdcf69a +Z b5c0c1b2ba1d5eb688c90f849be1cc0e diff --git a/manifest.uuid b/manifest.uuid index c66330ef8c..5c1e7191f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c6c8e01b31abfe2bc8e650bbfdb504021dc7e59 \ No newline at end of file +30ff6bb0b2d1068d28e86ac90bb9f454e4537a2d \ No newline at end of file diff --git a/src/main.c b/src/main.c index 5f231f1811..36fe82bbfa 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.460 2008/06/25 10:34:35 danielk1977 Exp $ +** $Id: main.c,v 1.461 2008/06/25 14:26:08 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -156,6 +156,14 @@ int sqlite3_config(int op, ...){ sqlite3MemSetMemsys3(pMem, nMem); break; } +#endif +#ifdef SQLITE_ENABLE_MEMSYS5 + case SQLITE_CONFIG_MEMSYS5: { + u8 *pMem = va_arg(ap, u8*); + int nMem = va_arg(ap, int); + sqlite3MemSetMemsys5(pMem, nMem); + break; + } #endif case SQLITE_CONFIG_MALLOC: { /* Specify an alternative malloc implementation */ diff --git a/src/mem5.c b/src/mem5.c index 198b0743e4..4ce5bf09e8 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -13,14 +13,17 @@ ** allocation subsystem for use by SQLite. ** ** This version of the memory allocation subsystem omits all -** use of malloc(). All dynamically allocatable memory is -** contained in a static array, mem.aPool[]. The size of this -** fixed memory pool is SQLITE_POW2_MEMORY_SIZE bytes. +** use of malloc(). The SQLite user supplies a block of memory +** before calling sqlite3_initialize() from which allocations +** are made and returned by the xMalloc() and xRealloc() +** implementations. Once sqlite3_initialize() has been called, +** the amount of memory available to SQLite is fixed and cannot +** be changed. ** -** This version of the memory allocation subsystem is used if -** and only if SQLITE_POW2_MEMORY_SIZE is defined. +** This version of the memory allocation subsystem is included +** in the build only if SQLITE_ENABLE_MEMSYS5 is defined. ** -** $Id: mem5.c,v 1.6 2008/06/18 17:09:10 danielk1977 Exp $ +** $Id: mem5.c,v 1.7 2008/06/25 14:26:08 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -28,7 +31,7 @@ ** This version of the memory allocator is used only when ** SQLITE_POW2_MEMORY_SIZE is defined. */ -#ifdef SQLITE_POW2_MEMORY_SIZE +#ifdef SQLITE_ENABLE_MEMSYS5 /* ** Log2 of the minimum size of an allocation. For example, if @@ -63,37 +66,32 @@ struct Mem5Block { union { char aData[POW2_MIN]; struct { - int next; /* Index in mem.aPool[] of next free chunk */ - int prev; /* Index in mem.aPool[] of previous free chunk */ + int next; /* Index in mem5.aPool[] of next free chunk */ + int prev; /* Index in mem5.aPool[] of previous free chunk */ } list; } u; }; -/* -** Number of blocks of memory available for allocation. -*/ -#define NBLOCK (SQLITE_POW2_MEMORY_SIZE/POW2_MIN) - /* ** The size in blocks of an POW2_MAX allocation */ #define SZ_MAX (1<<(NSIZE-1)) /* -** Masks used for mem.aCtrl[] elements. +** Masks used for mem5.aCtrl[] elements. */ #define CTRL_LOGSIZE 0x1f /* Log2 Size of this block relative to POW2_MIN */ #define CTRL_FREE 0x20 /* True if not checked out */ /* ** All of the static variables used by this module are collected -** into a single structure named "mem". This is to keep the +** into a single structure named "mem5". This is to keep the ** static variables organized and to reduce namespace pollution ** when this module is combined with other in the amalgamation. */ static struct { /* - ** The alarm callback and its arguments. The mem.mutex lock will + ** The alarm callback and its arguments. The mem5.mutex lock will ** be held while the callback is running. Recursive calls into ** the memory subsystem are allowed, but no new callbacks will be ** issued. The alarmBusy variable is set to prevent recursive @@ -130,142 +128,67 @@ static struct { ** Space for tracking which blocks are checked out and the size ** of each block. One byte per block. */ - u8 aCtrl[NBLOCK]; + u8 *aCtrl; /* ** Memory available for allocation */ - Mem5Block aPool[NBLOCK]; -} mem; + int nBlock; + Mem5Block *aPool; +} mem5; /* -** Unlink the chunk at mem.aPool[i] from list it is currently -** on. It should be found on mem.aiFreelist[iLogsize]. +** Unlink the chunk at mem5.aPool[i] from list it is currently +** on. It should be found on mem5.aiFreelist[iLogsize]. */ static void memsys5Unlink(int i, int iLogsize){ int next, prev; - assert( i>=0 && i=0 && i=0 && iLogsize=0 ){ - mem.aPool[next].u.list.prev = prev; + mem5.aPool[next].u.list.prev = prev; } } /* -** Link the chunk at mem.aPool[i] so that is on the iLogsize +** Link the chunk at mem5.aPool[i] so that is on the iLogsize ** free list. */ static void memsys5Link(int i, int iLogsize){ int x; - assert( sqlite3_mutex_held(mem.mutex) ); - assert( i>=0 && i=0 && i=0 && iLogsize=0 ){ - assert( x=POW2_MAX ); - mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); - sqlite3_mutex_enter(mem.mutex); - for(i=0; i=0 && i=0 && i=0 && iLogsize=0 ); while( i>0 ){ if( imem.maxRequest ){ - mem.maxRequest = nByte; + if( nByte>mem5.maxRequest ){ + mem5.maxRequest = nByte; } - /* Simulate a memory allocation fault */ - if( sqlite3FaultStep(SQLITE_FAULTINJECTOR_MALLOC) ) return 0; - /* Round nByte up to the next valid power of two */ if( nByte>POW2_MAX ) return 0; for(iFullSz=POW2_MIN, iLogsize=0; iFullSz=mem.alarmThreshold ){ - memsys5Alarm(iFullSz); - } - - /* Make sure mem.aiFreelist[iLogsize] contains at least one free + /* Make sure mem5.aiFreelist[iLogsize] contains at least one free ** block. If not, then split a block of the next larger power of ** two in order to create a new free block of size iLogsize. */ - for(iBin=iLogsize; mem.aiFreelist[iBin]<0 && iBin=NSIZE ) return 0; i = memsys5UnlinkFirst(iBin); while( iBin>iLogsize ){ @@ -352,48 +257,47 @@ static void *memsys5Malloc(int nByte){ iBin--; newSize = 1 << iBin; - mem.aCtrl[i+newSize] = CTRL_FREE | iBin; + mem5.aCtrl[i+newSize] = CTRL_FREE | iBin; memsys5Link(i+newSize, iBin); } - mem.aCtrl[i] = iLogsize; + mem5.aCtrl[i] = iLogsize; /* Update allocator performance statistics. */ - mem.nAlloc++; - mem.totalAlloc += iFullSz; - mem.totalExcess += iFullSz - nByte; - mem.currentCount++; - mem.currentOut += iFullSz; - if( mem.maxCount=0 && i=0 && i0 ); - assert( mem.currentOut>=0 ); - mem.currentCount--; - mem.currentOut -= size*POW2_MIN; - assert( mem.currentOut>0 || mem.currentCount==0 ); - assert( mem.currentCount>0 || mem.currentOut==0 ); - - mem.aCtrl[i] = CTRL_FREE | iLogsize; + assert( i+size-10 ); + assert( mem5.currentOut>=0 ); + mem5.currentCount--; + mem5.currentOut -= size*POW2_MIN; + assert( mem5.currentOut>0 || mem5.currentCount==0 ); + assert( mem5.currentCount>0 || mem5.currentOut==0 ); + + mem5.aCtrl[i] = CTRL_FREE | iLogsize; while( iLogsize=0 && iBuddy=0 && iBuddy0 ){ memsys5Enter(); - p = memsys5Malloc(nBytes); - sqlite3_mutex_leave(mem.mutex); + p = memsys5MallocUnsafe(nBytes); + memsys5Leave(); } return (void*)p; } @@ -435,49 +339,70 @@ void *sqlite3_malloc(int nBytes){ /* ** Free memory. */ -void sqlite3_free(void *pPrior){ +static void memsys5Free(void *pPrior){ if( pPrior==0 ){ return; } - assert( mem.mutex!=0 ); - sqlite3_mutex_enter(mem.mutex); - memsys5Free(pPrior); - sqlite3_mutex_leave(mem.mutex); + memsys5Enter(); + memsys5FreeUnsafe(pPrior); + memsys5Leave(); } /* ** Change the size of an existing memory allocation */ -void *sqlite3_realloc(void *pPrior, int nBytes){ +static void *memsys5Realloc(void *pPrior, int nBytes){ int nOld; void *p; if( pPrior==0 ){ - return sqlite3_malloc(nBytes); + return memsys5Malloc(nBytes); } if( nBytes<=0 ){ - sqlite3_free(pPrior); + memsys5Free(pPrior); return 0; } - assert( mem.mutex!=0 ); - nOld = sqlite3MallocSize(pPrior); + nOld = memsys5Size(pPrior); if( nBytes<=nOld ){ return pPrior; } - sqlite3_mutex_enter(mem.mutex); - p = memsys5Malloc(nBytes); + memsys5Enter(); + p = memsys5MallocUnsafe(nBytes); if( p ){ memcpy(p, pPrior, nOld); - memsys5Free(pPrior); + memsys5FreeUnsafe(pPrior); } - sqlite3_mutex_leave(mem.mutex); + memsys5Leave(); return p; } +/* +** Round up a request size to the next valid allocation size. +*/ +static int memsys5Roundup(int n){ + int iFullSz; + for(iFullSz=POW2_MIN; iFullSz=0; j = mem.aPool[j].u.list.next, n++){} + for(n=0, j=mem5.aiFreelist[i]; j>=0; j = mem5.aPool[j].u.list.next, n++){} fprintf(out, "freelist items of size %d: %d\n", POW2_MIN << i, n); } - fprintf(out, "mem.nAlloc = %llu\n", mem.nAlloc); - fprintf(out, "mem.totalAlloc = %llu\n", mem.totalAlloc); - fprintf(out, "mem.totalExcess = %llu\n", mem.totalExcess); - fprintf(out, "mem.currentOut = %u\n", mem.currentOut); - fprintf(out, "mem.currentCount = %u\n", mem.currentCount); - fprintf(out, "mem.maxOut = %u\n", mem.maxOut); - fprintf(out, "mem.maxCount = %u\n", mem.maxCount); - fprintf(out, "mem.maxRequest = %u\n", mem.maxRequest); - sqlite3_mutex_leave(mem.mutex); + fprintf(out, "mem5.nAlloc = %llu\n", mem5.nAlloc); + fprintf(out, "mem5.totalAlloc = %llu\n", mem5.totalAlloc); + fprintf(out, "mem5.totalExcess = %llu\n", mem5.totalExcess); + fprintf(out, "mem5.currentOut = %u\n", mem5.currentOut); + fprintf(out, "mem5.currentCount = %u\n", mem5.currentCount); + fprintf(out, "mem5.maxOut = %u\n", mem5.maxOut); + fprintf(out, "mem5.maxCount = %u\n", mem5.maxCount); + fprintf(out, "mem5.maxRequest = %u\n", mem5.maxRequest); + memsys5Leave(); if( out==stdout ){ fflush(stdout); }else{ @@ -514,5 +439,47 @@ void sqlite3MemdebugDump(const char *zFilename){ #endif } +/* +** This routine is the only routine in this file with external +** linkage. +** +** Populate the low-level memory allocation function pointers in +** sqlite3Config.m with pointers to the routines in this file. The +** arguments specify the block of memory to manage. +** +** This routine is only called by sqlite3_config(), and therefore +** is not required to be threadsafe (it is not). +*/ +void sqlite3MemSetMemsys5(u8 *zByte, int nByte){ + static const sqlite3_mem_methods memsys5Methods = { + memsys5Malloc, + memsys5Free, + memsys5Realloc, + memsys5Size, + memsys5Roundup, + memsys5Init, + memsys5Shutdown, + 0 + }; + int i; + + mem5.nBlock = (nByte / (sizeof(Mem5Block)+sizeof(u8))); + mem5.nBlock -= (mem5.nBlock%SZ_MAX); + mem5.aPool = (Mem5Block *)zByte; + mem5.aCtrl = (u8 *)&mem5.aPool[mem5.nBlock]; + + assert( sizeof(Mem5Block)==POW2_MIN ); + assert( mem5.nBlock>=SZ_MAX ); + assert( (mem5.nBlock%SZ_MAX)==0 ); + + for(i=0; i ** +**
SQLITE_CONFIG_MEMSYS5
+**
This option is only available if SQLite is compiled with the +** SQLITE_ENABLE_MEMSYS5 symbol defined. If available, then it is similar +** to the SQLITE_CONFIG_MEMSYS3 option. The "memsys5" allocator differs +** from the "memsys3" allocator in that it rounds all allocations up to +** the next largest power of two. Although this is sometimes more wasteful +** than the procudures used by memsys3, it guarantees an upper limit on +** internal fragmentation.
** */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ @@ -1129,6 +1137,7 @@ struct sqlite3_mem_methods { #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_MEMSYS3 12 /* u8*, int */ +#define SQLITE_CONFIG_MEMSYS5 13 /* u8*, int */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes {F12200} diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 7b94f368cc..34a69bcde5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.727 2008/06/25 10:34:35 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.728 2008/06/25 14:26:08 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1804,6 +1804,7 @@ void *sqlite3PageMalloc(int); void sqlite3PageFree(void*); void sqlite3MemSetDefault(void); void sqlite3MemSetMemsys3(u8 *pBlock, int nBlock); +void sqlite3MemSetMemsys5(u8 *pBlock, int nBlock); void sqlite3BenignMallocHooks(void (*)(void), void (*)(void)); #ifndef SQLITE_MUTEX_NOOP diff --git a/src/test_malloc.c b/src/test_malloc.c index 95b44ac5f4..dbb6fecf40 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -13,7 +13,7 @@ ** This file contains code used to implement test interfaces to the ** memory allocation subsystem. ** -** $Id: test_malloc.c,v 1.30 2008/06/25 10:34:35 danielk1977 Exp $ +** $Id: test_malloc.c,v 1.31 2008/06/25 14:26:09 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -931,18 +931,20 @@ static int test_config_pagecache( } /* -** Usage: sqlite3_config_memsys3 NBYTE +** Usage: +** +** sqlite3_config_memsys3 NBYTE +** sqlite3_config_memsys5 NBYTE ** */ static int test_config_memsys3( - void * clientData, + void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int sz, rc; - Tcl_Obj *pResult; - static char buf[1000000]; + static char buf[1048576]; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "NBYTE"); return TCL_ERROR; @@ -956,14 +958,17 @@ static int test_config_memsys3( if( sz>sizeof(buf) ){ sz = sizeof(buf); } - rc = sqlite3_config(SQLITE_CONFIG_MEMSYS3, buf, sz); + rc = sqlite3_config((int)clientData, buf, sz); } Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); return TCL_OK; } /* -** Usage: sqlite3_dump_memsys3 FILENAME +** Usage: +** +** sqlite3_dump_memsys3 FILENAME +** sqlite3_dump_memsys5 FILENAME ** ** Write a summary of unfreed memsys3 allocations to FILENAME. */ @@ -977,13 +982,23 @@ static int test_dump_memsys3( Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); return TCL_ERROR; } -#if defined(SQLITE_MEMDEBUG) || defined(SQLITE_MEMORY_SIZE) \ - || defined(SQLITE_POW2_MEMORY_SIZE) - { - extern void sqlite3Memsys3Dump(const char*); - sqlite3Memsys3Dump(Tcl_GetString(objv[1])); - } + + switch( (int)clientData ){ + case SQLITE_CONFIG_MEMSYS3: { +#ifdef SQLITE_ENABLE_MEMSYS3 + extern void sqlite3Memsys3Dump(const char*); + sqlite3Memsys3Dump(Tcl_GetString(objv[1])); + break; #endif + } + case SQLITE_CONFIG_MEMSYS5: { +#ifdef SQLITE_ENABLE_MEMSYS5 + extern void sqlite3Memsys5Dump(const char*); + sqlite3Memsys5Dump(Tcl_GetString(objv[1])); + break; +#endif + } + } return TCL_OK; } @@ -1069,31 +1084,35 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){ static struct { char *zName; Tcl_ObjCmdProc *xProc; + int clientData; } aObjCmd[] = { - { "sqlite3_malloc", test_malloc }, - { "sqlite3_realloc", test_realloc }, - { "sqlite3_free", test_free }, - { "memset", test_memset }, - { "memget", test_memget }, - { "sqlite3_memory_used", test_memory_used }, - { "sqlite3_memory_highwater", test_memory_highwater }, - { "sqlite3_memdebug_backtrace", test_memdebug_backtrace }, - { "sqlite3_memdebug_dump", test_memdebug_dump }, - { "sqlite3_memdebug_fail", test_memdebug_fail }, - { "sqlite3_memdebug_pending", test_memdebug_pending }, - { "sqlite3_memdebug_settitle", test_memdebug_settitle }, - { "sqlite3_memdebug_malloc_count", test_memdebug_malloc_count }, - { "sqlite3_memdebug_log", test_memdebug_log }, - { "sqlite3_config_scratch", test_config_scratch }, - { "sqlite3_config_pagecache", test_config_pagecache }, - { "sqlite3_config_memsys3", test_config_memsys3 }, - { "sqlite3_dump_memsys3", test_dump_memsys3 }, - { "sqlite3_status", test_status }, - { "install_malloc_faultsim", test_install_malloc_faultsim }, + { "sqlite3_malloc", test_malloc ,0. }, + { "sqlite3_realloc", test_realloc ,0. }, + { "sqlite3_free", test_free ,0. }, + { "memset", test_memset ,0. }, + { "memget", test_memget ,0. }, + { "sqlite3_memory_used", test_memory_used ,0. }, + { "sqlite3_memory_highwater", test_memory_highwater ,0. }, + { "sqlite3_memdebug_backtrace", test_memdebug_backtrace ,0. }, + { "sqlite3_memdebug_dump", test_memdebug_dump ,0. }, + { "sqlite3_memdebug_fail", test_memdebug_fail ,0. }, + { "sqlite3_memdebug_pending", test_memdebug_pending ,0. }, + { "sqlite3_memdebug_settitle", test_memdebug_settitle ,0. }, + { "sqlite3_memdebug_malloc_count", test_memdebug_malloc_count ,0. }, + { "sqlite3_memdebug_log", test_memdebug_log ,0. }, + { "sqlite3_config_scratch", test_config_scratch ,0. }, + { "sqlite3_config_pagecache", test_config_pagecache ,0. }, + { "sqlite3_status", test_status ,0. }, + { "install_malloc_faultsim", test_install_malloc_faultsim ,0. }, + { "sqlite3_config_memsys3", test_config_memsys3, SQLITE_CONFIG_MEMSYS3 }, + { "sqlite3_config_memsys5", test_config_memsys3, SQLITE_CONFIG_MEMSYS5 }, + { "sqlite3_dump_memsys3", test_dump_memsys3 , SQLITE_CONFIG_MEMSYS3 }, + { "sqlite3_dump_memsys5", test_dump_memsys3 , SQLITE_CONFIG_MEMSYS5 } }; int i; for(i=0; i