aboutsummaryrefslogtreecommitdiff
path: root/src/malloc.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-03-23 17:49:14 +0000
committerdrh <drh@noemail.net>2009-03-23 17:49:14 +0000
commit7047e25c4524878673ac36ba273bfd30a3d0614f (patch)
tree3c1f67aaf28a5483f357cac7fa96fc4a52be7f99 /src/malloc.c
parenta8bbef84bf3214905ceb9ea32fc249010dbde41a (diff)
downloadsqlite-7047e25c4524878673ac36ba273bfd30a3d0614f.tar.gz
sqlite-7047e25c4524878673ac36ba273bfd30a3d0614f.zip
Add asserts to make sure that database connection locks are held when
accessing the lookaside memory allocation buffers. No defects were found. (CVS 6374) FossilOrigin-Name: 8a9f3e66069146ad1b1bc2686567882dc87603a9
Diffstat (limited to 'src/malloc.c')
-rw-r--r--src/malloc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/malloc.c b/src/malloc.c
index 2678526ad..a995e2c0f 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -12,7 +12,7 @@
**
** Memory allocation functions used throughout sqlite.
**
-** $Id: malloc.c,v 1.59 2009/03/23 04:33:33 danielk1977 Exp $
+** $Id: malloc.c,v 1.60 2009/03/23 17:49:15 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -426,6 +426,7 @@ int sqlite3MallocSize(void *p){
return sqlite3GlobalConfig.m.xSize(p);
}
int sqlite3DbMallocSize(sqlite3 *db, void *p){
+ assert( db==0 || sqlite3_mutex_held(db->mutex) );
if( p==0 ){
return 0;
}else if( isLookaside(db, p) ){
@@ -455,6 +456,7 @@ void sqlite3_free(void *p){
** connection.
*/
void sqlite3DbFree(sqlite3 *db, void *p){
+ assert( db==0 || sqlite3_mutex_held(db->mutex) );
if( isLookaside(db, p) ){
LookasideSlot *pBuf = (LookasideSlot*)p;
pBuf->pNext = db->lookaside.pFree;
@@ -566,6 +568,7 @@ void *sqlite3DbMallocRaw(sqlite3 *db, int n){
#ifndef SQLITE_OMIT_LOOKASIDE
if( db ){
LookasideSlot *pBuf;
+ assert( sqlite3_mutex_held(db->mutex) );
if( db->mallocFailed ){
return 0;
}
@@ -597,6 +600,7 @@ void *sqlite3DbMallocRaw(sqlite3 *db, int n){
*/
void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){
void *pNew = 0;
+ assert( sqlite3_mutex_held(db->mutex) );
if( db->mallocFailed==0 ){
if( p==0 ){
return sqlite3DbMallocRaw(db, n);