diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/mem3.c | 7 | ||||
-rw-r--r-- | src/mem5.c | 4 | ||||
-rw-r--r-- | src/test_malloc.c | 13 |
4 files changed, 17 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c index 7a87860d7..3d4cd5360 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.477 2008/07/15 14:47:19 drh Exp $ +** $Id: main.c,v 1.478 2008/07/16 12:25:32 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -243,10 +243,10 @@ int sqlite3_config(int op, ...){ ** the default case and return an error. */ #ifdef SQLITE_ENABLE_MEMSYS3 - sqlite3Config.m = sqlite3MemGetMemsys3(); + sqlite3Config.m = *sqlite3MemGetMemsys3(); #endif #ifdef SQLITE_ENABLE_MEMSYS5 - sqlite3Config.m = sqlite3MemGetMemsys5(); + sqlite3Config.m = *sqlite3MemGetMemsys5(); #endif } break; diff --git a/src/mem3.c b/src/mem3.c index 38c89f77f..e276adef3 100644 --- a/src/mem3.c +++ b/src/mem3.c @@ -23,7 +23,7 @@ ** This version of the memory allocation subsystem is included ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined. ** -** $Id: mem3.c,v 1.18 2008/06/27 14:05:25 danielk1977 Exp $ +** $Id: mem3.c,v 1.19 2008/07/16 12:25:32 drh Exp $ */ #include "sqliteInt.h" @@ -498,8 +498,9 @@ void memsys3Free(void *pPrior){ ** works for chunks that are currently checked out. */ static int memsys3Size(void *p){ - Mem3Block *pBlock = (Mem3Block*)p; - assert( pBlock ); + Mem3Block *pBlock; + if( p==0 ) return 0; + pBlock = (Mem3Block*)p; assert( (pBlock[-1].u.hdr.size4x&1)!=0 ); return (pBlock[-1].u.hdr.size4x&~3)*2 - 4; } diff --git a/src/mem5.c b/src/mem5.c index 6161945d6..7ce28a342 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -23,7 +23,7 @@ ** This version of the memory allocation subsystem is included ** in the build only if SQLITE_ENABLE_MEMSYS5 is defined. ** -** $Id: mem5.c,v 1.10 2008/06/27 14:05:25 danielk1977 Exp $ +** $Id: mem5.c,v 1.11 2008/07/16 12:25:32 drh Exp $ */ #include "sqliteInt.h" @@ -46,7 +46,7 @@ ** Log2 of the maximum size of an allocation. */ #ifndef SQLITE_POW2_LOGMAX -# define SQLITE_POW2_LOGMAX 18 +# define SQLITE_POW2_LOGMAX 20 #endif #define POW2_MAX (((unsigned int)1)<<SQLITE_POW2_LOGMAX) diff --git a/src/test_malloc.c b/src/test_malloc.c index b67bcccab..052f198ea 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.37 2008/07/11 16:15:18 drh Exp $ +** $Id: test_malloc.c,v 1.38 2008/07/16 12:25:32 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -967,7 +967,8 @@ static int test_config_heap( int objc, Tcl_Obj *CONST objv[] ){ - static char zBuf[1048576]; + static char *zBuf; /* Use this memory */ + static int szBuf; /* Bytes allocated for zBuf */ int nByte; /* Size of buffer to pass to sqlite3_config() */ int nMinAlloc; /* Size of minimum allocation */ int rc; /* Return code of sqlite3_config() */ @@ -983,11 +984,13 @@ static int test_config_heap( if( Tcl_GetIntFromObj(interp, aArg[1], &nMinAlloc) ) return TCL_ERROR; if( nByte==0 ){ + free( zBuf ); + zBuf = 0; + szBuf = 0; rc = sqlite3_config(SQLITE_CONFIG_HEAP, (void*)0, 0, 0); }else{ - if( nByte>sizeof(zBuf) ){ - nByte = sizeof(zBuf); - } + zBuf = realloc(zBuf, nByte); + szBuf = nByte; rc = sqlite3_config(SQLITE_CONFIG_HEAP, zBuf, nByte, nMinAlloc); } |