diff options
author | drh <drh@noemail.net> | 2010-06-26 20:25:30 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-06-26 20:25:30 +0000 |
commit | 37f99187589962dc5338cdf21eb71f376e972d1a (patch) | |
tree | 6568e3691200a95826bdedb59af7af743ebbda32 /src | |
parent | 7d113eb0aba33281db9b8d2204747cd8858a946f (diff) | |
download | sqlite-37f99187589962dc5338cdf21eb71f376e972d1a.tar.gz sqlite-37f99187589962dc5338cdf21eb71f376e972d1a.zip |
Fix two asserts on the scratch allocator to allow for up to two outstanding
scratch allocations per thread.
FossilOrigin-Name: f149b498b6ada3fc9f71ee104c351554c80c7f8a
Diffstat (limited to 'src')
-rw-r--r-- | src/malloc.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/malloc.c b/src/malloc.c index 6d3b3002e..c7f8a191c 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -315,11 +315,11 @@ void *sqlite3ScratchMalloc(int n){ assert( n>0 ); #if SQLITE_THREADSAFE==0 && !defined(NDEBUG) - /* Verify that no more than one scratch allocation per thread + /* Verify that no more than two scratch allocation per thread ** is outstanding at one time. (This is only checked in the ** single-threaded case since checking in the multi-threaded case ** would be much more complicated.) */ - assert( scratchAllocOut==0 ); + assert( scratchAllocOut<=1 ); #endif if( sqlite3GlobalConfig.szScratch<n ){ @@ -364,16 +364,6 @@ scratch_overflow: } void sqlite3ScratchFree(void *p){ if( p ){ - -#if SQLITE_THREADSAFE==0 && !defined(NDEBUG) - /* Verify that no more than one scratch allocation per thread - ** is outstanding at one time. (This is only checked in the - ** single-threaded case since checking in the multi-threaded case - ** would be much more complicated.) */ - assert( scratchAllocOut==1 ); - scratchAllocOut = 0; -#endif - if( sqlite3GlobalConfig.pScratch==0 || p<sqlite3GlobalConfig.pScratch || p>=(void*)mem0.aScratchFree ){ @@ -399,6 +389,16 @@ void sqlite3ScratchFree(void *p){ mem0.aScratchFree[mem0.nScratchFree++] = i; sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); sqlite3_mutex_leave(mem0.mutex); + +#if SQLITE_THREADSAFE==0 && !defined(NDEBUG) + /* Verify that no more than two scratch allocation per thread + ** is outstanding at one time. (This is only checked in the + ** single-threaded case since checking in the multi-threaded case + ** would be much more complicated.) */ + assert( scratchAllocOut>=1 && scratchAllocOut<=2 ); + scratchAllocOut = 0; +#endif + } } } |