aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/btree.c3
-rw-r--r--src/main.c4
-rw-r--r--src/mem2.c10
-rw-r--r--src/mutex.h3
-rw-r--r--src/random.c4
-rw-r--r--src/sqliteInt.h12
6 files changed, 24 insertions, 12 deletions
diff --git a/src/btree.c b/src/btree.c
index 9bc560dcd..e2f41ec0f 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -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
diff --git a/src/main.c b/src/main.c
index 4f61cd2ba..870b9f30f 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.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;
diff --git a/src/mem2.c b/src/mem2.c
index 2400ce0ba..304c9fbb0 100644
--- a/src/mem2.c
+++ b/src/mem2.c
@@ -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;
diff --git a/src/mutex.h b/src/mutex.h
index 5ed8ee369..0088ad489 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -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
diff --git a/src/random.c b/src/random.c
index f3741c32e..f32823279 100644
--- a/src/random.c
+++ b/src/random.c
@@ -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();
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 7097bf60c..d5e2c74bf 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -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);