]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Bug fixes: Plug a memory leak introduced by the previous check-in. Get
authordrh <drh@noemail.net>
Thu, 19 Jun 2008 01:03:17 +0000 (01:03 +0000)
committerdrh <drh@noemail.net>
Thu, 19 Jun 2008 01:03:17 +0000 (01:03 +0000)
the amalgamation to the point where it will compile. (CVS 5241)

FossilOrigin-Name: 005f8eaef5ae05cef5c76f3afe299eaa2cf8af2f

manifest
manifest.uuid
src/btree.c
src/main.c
src/mem2.c
src/mutex.h
src/random.c
src/sqliteInt.h

index b3ae349dab4a2a27d9c866f3d1174ba70a245e07..a20289dfbf1d94e8107f8e1e8d7aa80b5e1eee33 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\ssome\stest\slogic\sto\sthe\snew\smemory\sallocation\ssubsystem.\s\s(Lots\smore\sneeded.)\nThe\stest\ssuite\sis\scurrently\sindicating\smemory\sleaks,\sthough\sit\sis\sunclear\sif\nthis\sis\sa\strue\scode\sproblem\sor\sjust\san\sinstrumentation\sproblem.\s(CVS\s5240)
-D 2008-06-19T00:16:08
+C Bug\sfixes:\s\sPlug\sa\smemory\sleak\sintroduced\sby\sthe\sprevious\scheck-in.\s\sGet\nthe\samalgamation\sto\sthe\spoint\swhere\sit\swill\scompile.\s(CVS\s5241)
+D 2008-06-19T01:03:18
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in ff6f90048555a0088f6a4b7406bed5e55a7c4eff
 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 a7c8e782cf6a36eb4b15f263200215b572f95406
+F src/btree.c 54a5e5f84657e57313be156cdf47dfc8d1182b39
 F src/btree.h b1bd7e0b8c2e33658aaf447cb0d1d94f74664b6b
 F src/btreeInt.h 02325f04758dba0fcd0c08ac55cd9b189dad61a5
 F src/build.c 88cc5501a87f72d0538b040001d88d31f994edea
@@ -115,16 +115,16 @@ F src/insert.c c2ead6c36566de8e3f130e7ab1431723a269d5d7
 F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
 F src/legacy.c 3626c71fb70912abec9a4312beba753a9ce800df
 F src/loadext.c 2ac671f42a8ce15e2a58155b9d7f6c61eb7e127e
-F src/main.c cac2d0736589536c2a11a80676b18806dabff21f
+F src/main.c d75dad89c689c92cfb20d45f3ef31baca08eb896
 F src/malloc.c 33b8a20684e65ce13f94e5b14fb0e6cdc335c5d1
 F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
 F src/mem1.c 159f10e280f2d9aea597cf938851e61652dd5c3d
-F src/mem2.c 468a7fd5e0ce1909cfb554d7589af1d4a61f14bb
+F src/mem2.c 23f9538f35fbcd5665afe7056a56be0c7ed65aa7
 F src/mem3.c 28b4812b87470a00b11821fb5850e7cabcce06c6
 F src/mem4.c 6703adb1717b26d9d70a1c2586b4b7b7ffee7909
 F src/mem5.c ad31a0a481b86b86f4ac0b6d952e69727d4e113a
 F src/mutex.c 67393ac4e82d2ff09622ec33b9f289deb9d8825e
-F src/mutex.h 62ce61355b7a10a7c262e71aa9ed848a945a9353
+F src/mutex.h e9f3a02e58e6858b0c4e29bb8a4bc811807f3178
 F src/mutex_os2.c d9eb88ad198c59f1a45d90b597c258562a40e52c
 F src/mutex_unix.c 469a35c105435794375d683f75cad9e848817d19
 F src/mutex_w32.c e03baa369c5e8e7ea4dd2e5b3d098e047f7a2f06
@@ -140,12 +140,12 @@ F src/parse.y 8c2c3145eebe1964eb279cb3c4e502eae28bb0fa
 F src/pragma.c 70e7c865dce85fdf9df81848af2169009a56ed08
 F src/prepare.c 3c19149e75fbf3b08471a389f064da7302cad9c5
 F src/printf.c 8b063da9dcde26b7c500a01444b718d86f21bc6e
-F src/random.c 362b62e26db90ec9296903377a9d74b4669aa515
+F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a
 F src/select.c 669687459e7d0193c89de06c5dbed55b4a41191c
 F src/shell.c a12ea645271b7876c8f080146f48e20b00d367ec
 F src/sqlite.h.in f69427508e76eec76dae7f5fffdfefc05a9d4329
 F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
-F src/sqliteInt.h 8c2532dd9f53b05d2d6ec9e772d726718a0d4ac6
+F src/sqliteInt.h 6dd55232e738a4dac23475cd4b0e444dff75c896
 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
 F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
 F src/tclsqlite.c 4dd9ee4cb44846ad9bcc4d0da8088c1e7d4b33d9
@@ -598,7 +598,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 8b14a220f261b354e7d2d16dc3fe30c5d3d34143
-R a54a916e07bd9133d83929df10e422cc
+P cb1f11cd9764cf0275e88e1f6342e366e5536bfd
+R d31a6f690398344ca4203edcb0e9db61
 U drh
-Z 67cf172775ef7e1849c4e693b07767c0
+Z 8c5da773b6bfb26a8c5d93d48d8bcf9f
index ca9552a15d520902ba4ca07cbb5b660dea5a29b7..901b1be6d799de06c25e8b41ac6b02957e6ecb52 100644 (file)
@@ -1 +1 @@
-cb1f11cd9764cf0275e88e1f6342e366e5536bfd
\ No newline at end of file
+005f8eaef5ae05cef5c76f3afe299eaa2cf8af2f
\ No newline at end of file
index 9bc560dcde1c35b9a804c15c0adcbd222ebc6c78..e2f41ec0f3be9b3874bc52a49b22538904ec05e8 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.467 2008/06/19 00:16:08 drh Exp $
+** $Id: btree.c,v 1.468 2008/06/19 01:03:18 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -1463,6 +1463,7 @@ int sqlite3BtreeClose(Btree *p){
     }
     sqlite3_free(pBt->pSchema);
     freeTempSpace(pBt);
+    sqlite3_free(pBt);
   }
 
 #ifndef SQLITE_OMIT_SHARED_CACHE
index 4f61cd2ba345d8579715cea5fe32e13474c9e0ea..870b9f30f6f8eab23a8228634f3752bec85e002e 100644 (file)
@@ -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.451 2008/06/19 00:16:08 drh Exp $
+** $Id: main.c,v 1.452 2008/06/19 01:03:18 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -76,7 +76,9 @@ int sqlite3_initialize(void){
   if( sqlite3IsInit ) return SQLITE_OK;
   rc = sqlite3MutexInit();
   if( rc==SQLITE_OK ){
+#ifndef SQLITE_MUTEX_NOOP
     sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
+#endif
     sqlite3_mutex_enter(pMutex);
     if( sqlite3IsInit==0 ){
       sqlite3IsInit = 1;
index 2400ce0ba1c729f68cd8904b097b0838ced7b756..304c9fbb0f9e8757227b9616ff4f701a4a4ba843 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.32 2008/06/18 17:09:10 danielk1977 Exp $
+** $Id: mem2.c,v 1.33 2008/06/19 01:03:18 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -162,7 +162,11 @@ static int sqlite3MemSize(void *p){
 ** Initialize the memory allocation subsystem.
 */
 static int sqlite3MemInit(void *NotUsed){
-  mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
+  if( !sqlite3Config.bMemstat ){
+    /* If memory status is enabled, then the malloc.c wrapper will already
+    ** hold the STATIC_MEM mutex when the routines here are invoked. */
+    mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
+  }
   return SQLITE_OK;
 }
 
@@ -248,7 +252,7 @@ static void sqlite3MemFree(void *pPrior){
   struct MemBlockHdr *pHdr;
   void **pBt;
   char *z;
-  assert( mem.mutex!=0 );
+  assert( sqlite3Config.bMemstat || mem.mutex!=0 );
   pHdr = sqlite3MemsysGetHeader(pPrior);
   pBt = (void**)pHdr;
   pBt -= pHdr->nBacktraceSlots;
index 5ed8ee3698003af6d1eef1ecd51c0a5d0c9a8cf3..0088ad489ecfb05c093bc5f9e68f9e0d1923a66e 100644 (file)
@@ -19,7 +19,7 @@
 ** Source files should #include the sqliteInt.h file and let that file
 ** include this one indirectly.
 **
-** $Id: mutex.h,v 1.5 2008/06/18 18:57:42 danielk1977 Exp $
+** $Id: mutex.h,v 1.6 2008/06/19 01:03:18 drh Exp $
 */
 
 
@@ -77,6 +77,7 @@
 #define sqlite3_mutex_leave(X)
 #define sqlite3_mutex_held(X)     1
 #define sqlite3_mutex_notheld(X)  1
+#define sqlite3MutexAlloc(X)      0
 #define sqlite3MutexInit()        SQLITE_OK
 #define sqlite3MutexEnd()
 #endif
index f3741c32eb5ce5841a0bf3d0651444c0434c053b..f3282327913c2377d7e69919dcaf5c64946f62cd 100644 (file)
@@ -15,7 +15,7 @@
 ** Random numbers are used by some of the database backends in order
 ** to generate random integer keys for tables or random filenames.
 **
-** $Id: random.c,v 1.24 2008/06/18 17:09:10 danielk1977 Exp $
+** $Id: random.c,v 1.25 2008/06/19 01:03:18 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -92,7 +92,9 @@ static int randomByte(void){
 */
 void sqlite3_randomness(int N, void *pBuf){
   unsigned char *zBuf = pBuf;
+#ifndef SQLITE_MUTEX_NOOP
   sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);
+#endif
   sqlite3_mutex_enter(mutex);
   while( N-- ){
     *(zBuf++) = randomByte();
index 7097bf60c97e37c7e90dd76d75d51a89941308cf..d5e2c74bff55c6f7dc06a64c1b098c1e67270d26 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.716 2008/06/19 00:16:08 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.717 2008/06/19 01:03:18 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -1805,10 +1805,12 @@ void *sqlite3PageMalloc(int);
 void sqlite3PageFree(void*);
 void sqlite3MemSetDefault(void);
 
-sqlite3_mutex_methods *sqlite3DefaultMutex(void);
-sqlite3_mutex *sqlite3MutexAlloc(int);
-int sqlite3MutexInit(void);
-int sqlite3MutexEnd(void);
+#ifndef SQLITE_MUTEX_NOOP
+  sqlite3_mutex_methods *sqlite3DefaultMutex(void);
+  sqlite3_mutex *sqlite3MutexAlloc(int);
+  int sqlite3MutexInit(void);
+  int sqlite3MutexEnd(void);
+#endif
 
 void sqlite3StatusReset(void);
 int sqlite3StatusValue(int);